|
j4cbo posted:This is because the size of any pointer must be a multiple of the size of a single char, and if pointers are of finite dimension The first part of this does not imply the second part.
|
# ¿ Apr 13, 2009 04:20 |
|
|
# ¿ May 17, 2024 13:33 |
|
j4cbo posted:The sizeof operator result "is an integer" according to the spec, so it can't be infinity. Or is that not what you meant? "Integer" in the ISO standard is understood to refer to the integral types in the language, which make no explicit mandate that the values be finite. It's being pedantic, but so are you. (It would be stupid, for instance, for sizeof to return an integer larger than can be represented by the available integral types, so just "is an element of Z" isn't what the standard is referring to. Besides that, the grammar rules for integer constants clearly allow constants of infinite length.) Incidentally, a conforming implementation of ISO C can have unbounded char values if it wants. The standard says nothing whatsoever about the size of a byte, and in fact goes out of its way to provide for systems where a byte is not 8 bits. Avenging Dentist fucked around with this message at 04:46 on Apr 13, 2009 |
# ¿ Apr 13, 2009 04:39 |
|
j4cbo posted:Infinite and unbounded (arbitrarily large) aren't the same thing. And yes, of course I'm being pedantic. If you have infinite space (required for TC) you can define a decimal integer literal equal to aleph-0 (by way of writing a decimal expansion with aleph-0 digits). I mean, that's part of the basis of the proof that R is uncountable.
|
# ¿ Apr 13, 2009 05:04 |
|
dancavallaro posted:This speaks for itself: A question so bad, even StackOverflow shits on it.
|
# ¿ Apr 27, 2009 17:00 |
|
twodot posted:If you've been doing C for long enough you start to write code with format string vulnerabilities in it? Congrats, you don't know printf.
|
# ¿ May 4, 2009 16:31 |
|
rjmccall posted:If print were actually printf, then print a would indeed have format-string vulnerabilities. But it isn't; the printf-like thing in that code is python's % operator, which is essentially sprintf. I think he is trying to assert that, in C, printf("%s",s); has a format-string vulnerability. Which is false.
|
# ¿ May 4, 2009 18:25 |
|
Seth Turtle posted:Where do people come up with this insanity? Is it really that hard to code in a sane and understandable manner? Given that people make functions called doit or run in Java, yes.
|
# ¿ May 11, 2009 17:12 |
|
thesaddestpirate posted:
Um, thank you for agreeing with me that Java is horrible?
|
# ¿ May 11, 2009 22:19 |
|
rhag posted:May I please get some? Been using it for so long, I've never had a problem with Runnable->run, Thread->start, Cloneable->clone (even tho clone is part of Object). The fact that there are multiple, differently-named methods in Java that amount to "doit()" is pretty bad. For as much poo poo as operator overloading gets, at least with using the call operator, you aren't forced to come up with vague method names that vary depending on the specific usage. As for bad naming in general, let's just go through the Javadoc alphabetically, shall we? code:
|
# ¿ May 13, 2009 19:03 |
|
Seth Turtle posted:It could be worse. The classes could be abbreviated to AAVV and AQLSync. Or you could use something called "namespaces" and allow people to apply using declarations to minimize verbosity. A radical idea, I know.
|
# ¿ May 13, 2009 23:53 |
|
rhag posted:Am I weird for not finding those names...bad? I don't see the problem with a 20 character long class name. I mean, I would have had such a problem back in Borland C++ 3.1 days, but today, with today's IDE's, its all a CTRL+space away. Yes. You are weird. It's not even about typing them, it's about reading them. Anything nontrivial with any of those functions (and given Java's propensity for verbosity, that's 99% of things) is going to be spread out on multiple lines or will just scroll horizontally off the screen. A good sign that your code is poo poo is when a majority of the individual statements have to wrapped to fit on the screen.
|
# ¿ May 14, 2009 01:13 |
|
If you don't program with (at least) 2 columns of code side-by-side, you are not a real programmer.rhag posted:don't do Java The only true statement in that entire post.
|
# ¿ May 14, 2009 01:51 |
|
No Safe Word posted:Hell I do and I still have an 80-column limitation. Newspaper/magazine articles have short columns for a reason: it's easier to read.
|
# ¿ May 14, 2009 01:57 |
|
rjmccall posted:2. The import system lacks shortened qualified import, which turns name collisions into minor catastrophes (because everyone uses prolix package names), which means you see some really silly workarounds like Swing's J prefix on every single class in the library. This was my favorite part of reading through the Javadoc. C++ has an awful "package" management system, and even it can avoid the old-school C way of applying prefixes to identifiers to avoid name collisions. Any language made after C just has no excuse for that.
|
# ¿ May 14, 2009 02:52 |
|
Brain Candy posted:Thread is a thread, Runnable is a functor that you put in threads. Would you like ThreadFunctorActionier instead? Thanks for not reading what I wrote?
|
# ¿ May 15, 2009 06:59 |
|
Otto Skorzeny posted:This* is why warnings and strict should have defaulted to on since like 1995 Ummmmm gently caress you buddy? Barewords are a great way of cutting out a few keystrokes in Perl Golf.
|
# ¿ Jun 12, 2009 17:58 |
|
A A 2 3 5 8 K posted:http://codytaylor.org/?p=14122 Urge to update Blogging Considered Harmful... rising...
|
# ¿ Jun 16, 2009 04:10 |
|
Vinterstum posted:Looks like it was for Visual Studio compatibility: http://bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=3638&p=13749&hilit=std%3A%3Avector#p13749 Hate to break it to you, but Visual Studio's STL implementation is by Dinkumware and is generally regarded as being pretty good. (Also if your problem with an implementation of the STL is that it doesn't let you violate the standard then you are probably an idiot.) Avenging Dentist fucked around with this message at 08:04 on Jul 2, 2009 |
# ¿ Jul 2, 2009 07:59 |
|
Vinterstum posted:1. The Bullet guys needed some of their data to be 16 byte aligned. Yeah cuz writing an allocator is really hard. This isn't even one of those situations where it's a weird allocator like EASTL needed. (The resize thing is an issue but who actually uses vectors anyway? Hurp durp arrays are hard better use a class that allocates up to the next power of two for space so I have amortized constant-time insertion at the end. Oh also vector<bool> is hilarious.) There are like a million problems with the STL and it amuses me that when people write their own generic container classes, they solve 1% of the problems, replicate the 99% remaining, and then add a few of their own for flavor. Avenging Dentist fucked around with this message at 18:39 on Jul 2, 2009 |
# ¿ Jul 2, 2009 18:28 |
|
Janin posted:And in the end, the error was somewhere else, so I couldn't make any changes You need to learn how to lie.
|
# ¿ Jul 3, 2009 19:03 |
|
Jon93 posted:I like reading this thread for "What no to do"(s). But I wish you explained why what you posted is wrong and the correct way they should have done it, more often. You can't teach people that way. They'll (you'll) just make equally dubious decisions that are ever-so-slightly different from what's listed here. Everyone's got (at least) 10,000 lines of awful code in them so you just have to get that out of your systyem first.
|
# ¿ Jul 5, 2009 20:27 |
|
Otto Skorzeny posted:We had a fun time in the channel kicking around why Linus might have chosen the ((void)0) construct. What do you mean? That's idiomatic C for "do nothing".
|
# ¿ Jul 7, 2009 21:22 |
|
Lexical Unit posted:What about putting them in a union with an unsigned integer type, byteswapping the integer and returning the integer? The integer can go over whatever I/O it needs to and be byteswapped back into a floating point type on the other end. Accessing a value stored in a union from a type other than the one that it was stored with is a violation of strict-aliasing (with the exception of accessing via char*). Furthermore, y'all need to shut up about the original code being unsafe since it casts to a char* and that's guaranteed to be safe by the ISO standard. EDIT: Since I don't want to write an essay on this, I will defer to a good source: http://www.cellperformance.com/mike_acton/2006/06/understanding_strict_aliasing.html Avenging Dentist fucked around with this message at 04:21 on Jul 8, 2009 |
# ¿ Jul 8, 2009 04:06 |
|
There is literally nothing in the C99/C++03 standards* that says you can't manipulate a floating point value from casting/type-punning to a char*. I don't see why people are obsessing about this for. * Probably the same for other versions of C and C++, but I don't have access to the specs.
|
# ¿ Jul 8, 2009 04:24 |
|
Lexical Unit posted:Probably due to lovely websites found through google: Then yeah keep the swapped data in a char buffer. (Also note that I didn't say anything about manipulating the value of a floating-point number in a predictable way. ) (Also also you should really be using type traits to disable that if it's not a primitive type). Avenging Dentist fucked around with this message at 04:57 on Jul 8, 2009 |
# ¿ Jul 8, 2009 04:45 |
|
Lexical Unit posted:Edit: Wait, I think I misread that. Did you mean should or souldn't? I already mentioned that I used type traits to clamp that poo poo down. I said primitive, not integral. (There's also no reason that byteswapped data needs to be returned with the same type as the original; in fact it would be more sensible to return it as a char buffer, since you really shouldn't be manipulating byteswapped data as though it were of the original type, floating-point or not. What I am saying here is "make it work with integral and floating point values and nothing else".)
|
# ¿ Jul 8, 2009 05:46 |
|
RussianManiac posted:I must be missing something. If you do #define __(a) ( ) then all you are doing is just getting rid of arguments to a function prototype, right, but the return type and name should still be there assuming that it looks like Yes, hence K&R syntax. (Except that functions don't have prototypes in K&R C.)
|
# ¿ Jul 9, 2009 07:45 |
|
Once you see someone use "fail" as a noun you can pretty much ignore everything else they say since they are human scum.
|
# ¿ Jul 9, 2009 19:17 |
|
Zombywuf posted:http://www.askoxford.com/concise_oed/fail?view=uk Believe it or not, the OED doesn't tell you which words are stupid.
|
# ¿ Jul 9, 2009 19:41 |
|
Zombywuf posted:However you have just called dictionary corner human scum. This is tantamount to a declaration of war on the UK. Um yeah, I'm an American, we have a habit of fighting the UK.
|
# ¿ Jul 9, 2009 20:39 |
|
So, I'm sure some of you know that C++'s throw specifiers don't always work too well, even for the no-throw case, e.g. void my_func() throw() {}. Luckily, the C++ standards committee has decided to resolve this, but since it's fairly late in the standardization game, they're worried about adding any new keywords, so they're reusing some old ones:code:
|
# ¿ Jul 24, 2009 00:04 |
|
Scaevolus posted:What's wrong with it? The sine function generally does not range from -0.0174532778 to 0.0174532778.
|
# ¿ Jul 24, 2009 04:14 |
|
Scaevolus posted:The only thing I can find wrong with it is that it uses degrees instead of gradians. Why would a system that uses 400 units for the angle of a circle be better?
|
# ¿ Jul 24, 2009 05:22 |
|
Scaevolus posted:Why would a 404 help your point? If you can't be bothered to figure out what the URL should be, perhaps you should go and hit the books?
|
# ¿ Jul 24, 2009 05:26 |
|
Scaevolus posted:3 char extensions should be good enough for anyone! You know, if you got a 3-char extension maybe you wouldn't be a 2-bit poster anymore!
|
# ¿ Jul 24, 2009 05:28 |
|
geetee posted:It's almost as if there used to be a line of code under "foo". People have an unhealthy obsession with switch statements though (especially in languages like C# or Java). I mean ok, sure, in C/C++ with a sub-optimal compiler, a switch statement might be faster than if/elses by implementing it as a jump table (a smart compiler should be able to figure this out too for if/elses), but that sort of thing isn't going to work with string comparisons.
|
# ¿ Jul 24, 2009 20:35 |
|
Flobbster posted:I went to search Google for some statistics on when C#'s compile-string-switches-to-a-hashtable approach becomes more/less efficient than a chain of if/elses I would hope that the compiler would notice that you're using a chain of if/elses and transform them into a switch statement in the IL.
|
# ¿ Jul 24, 2009 21:07 |
|
BattleMaster posted:Not all if/else chains translate into a switch/case block, and if they do you just wasted a lot more time typing it out like that. Do you really have that hard a time writing else if(foo== compared to break? BattleMaster posted:Also there's no good way to represent two consecutive labels with no break statement in between within a switch/case block if you type it out as an if/else chain. They don't have the boolean-or operator where you're from? Switch statements are useful, but people use them a lot of times because they think it makes them clever. Unless you're writing Duff's Device (and you shouldn't), you're not being clever. See the above example for a good misuse of switches, since I guess using boolean arithmetic just wasn't enough fun.
|
# ¿ Jul 25, 2009 00:02 |
|
A real man would use the GCC frontend with LLVM to compile to (optimized) C and then compile with the old-n-busted compiler you've got.
|
# ¿ Jul 25, 2009 02:47 |
|
|
# ¿ May 17, 2024 13:33 |
|
If the compilers support functions, if statements, and gotos you'll probably be ok.
|
# ¿ Jul 25, 2009 02:54 |