|
Skuto posted:Only in strict mode. In ES6 it's back with different prefixes, one of which I'm going to mention because it's appropriate here: 0O. (Admittedly I can't think of a case in which that would cause bugs, no matter how silly it looks) Which javascript environment are you using that says 08 as an octal? Separately, the ES6 spec at least as of July says numbers beginning with 0 should be a decimal number.. Edit: It seems in node/firefox/chrome any invalid octal number returns the decimal equivalent... which sounds worse than throwing an error. Strong Sauce fucked around with this message at 23:40 on Aug 6, 2014 |
# ? Aug 6, 2014 23:31 |
|
|
# ? May 17, 2024 02:12 |
|
== true does have a legitimate use case in any language with truthy values other boolean true, am I misunderstanding something or why is this discussion happening?
|
# ? Aug 6, 2014 23:55 |
|
xtal posted:== true does have a legitimate use case in any language with truthy values other boolean true, am I misunderstanding something or why is this discussion happening? Wanting to specifically distinguish true from other truthy values nearly always means you've doing something very stupid.
|
# ? Aug 7, 2014 00:01 |
|
code:
This goes on all the way up to // 42. Knyteguy fucked around with this message at 03:51 on Aug 7, 2014 |
# ? Aug 7, 2014 01:07 |
|
Jesus, the part of my brain devoted to JS type semantics must finally be being reclaimed.
|
# ? Aug 7, 2014 01:12 |
|
Strong Sauce posted:Which javascript environment are you using that says 08 as an octal? https://mail.mozilla.org/pipermail/es-discuss/2014-August/038596.html Can't ~break the web~, man.
|
# ? Aug 7, 2014 01:41 |
|
Vanadium posted:https://mail.mozilla.org/pipermail/es-discuss/2014-August/038596.html Sort of pointless to do so, too, in this case.
|
# ? Aug 7, 2014 02:18 |
|
Plorkyeran posted:Wanting to specifically distinguish true from other truthy values nearly always means you've doing something very stupid. Or a library is, but yeah.
|
# ? Aug 7, 2014 02:58 |
|
Okay so I guess Skuto used a nightly version that threw an error for him about 08?
|
# ? Aug 7, 2014 16:15 |
|
Strong Sauce posted:Okay so I guess Skuto used a nightly version that threw an error for him about 08? I saw some tweets about the issue on my stream, and thought it was hilarious after seeing the date example, in the saddest sense of that word.
|
# ? Aug 7, 2014 16:24 |
|
Picture, if you will, a codebase in which the .h files are all symlinks to the corresponding .c files, most of which then #include themselves recursively.
|
# ? Aug 7, 2014 18:56 |
|
I tried, but I can't. How do you not get duplicate symbols?
|
# ? Aug 7, 2014 20:15 |
|
Different bits of the files are used each time they're included, depending on which symbols are already defined. I wish I was joking.
|
# ? Aug 7, 2014 20:34 |
|
Soricidus posted:Picture, if you will, a codebase in which the .h files are all symlinks to the corresponding .c files, most of which then #include themselves recursively. This is an awesome way to say "I hate you and myself"
|
# ? Aug 7, 2014 21:24 |
|
Soricidus posted:Picture, if you will, a codebase in which the .h files are all symlinks to the corresponding .c files, most of which then #include themselves recursively. All I get is that scene in π where he takes a drill to his own head except I'm the guy
|
# ? Aug 7, 2014 21:35 |
|
Soricidus posted:Picture, if you will, a codebase in which the .h files are all symlinks to the corresponding .c files, most of which then #include themselves recursively. Time works the same way.
|
# ? Aug 7, 2014 21:37 |
|
There was a discussion last page on "if (x == true)" being bad form because generally "if (x)" is the better alternative. What about "if (!x)" versus "if (x == false)"?
|
# ? Aug 7, 2014 22:57 |
|
Soricidus posted:Different bits of the files are used each time they're included, depending on which symbols are already defined. Purify your code base and coworkers with cleansing fire.
|
# ? Aug 7, 2014 23:01 |
|
Knyteguy posted:There was a discussion last page on "if (x == true)" being bad form because generally "if (x)" is the better alternative. I'd say it's the same. It's also more readable if you use descriptive names. code:
|
# ? Aug 7, 2014 23:18 |
|
Volmarias posted:Purify your code base and coworkers with cleansing fire. Knyteguy posted:There was a discussion last page on "if (x == true)" being bad form because generally "if (x)" is the better alternative.
|
# ? Aug 8, 2014 00:06 |
|
eithedog posted:If anybody's interested, in JS, for example: That's not fair. Using js is cheating. Knyteguy posted:There was a discussion last page on "if (x == true)" being bad form because generally "if (x)" is the better alternative. I don't think either form is actually any less clear than the other. Just write whichever feels natural.
|
# ? Aug 8, 2014 00:20 |
|
Knyteguy posted:There was a discussion last page on "if (x == true)" being bad form because generally "if (x)" is the better alternative. Once upon a time the related if (p == NULL) might've made sense (in C at least), if you couldn't count on NULL being falsy. But I think it's been standardized as 0 for quite some time now. In other languages you've got various definitions of "falsy" and various behaviours of the == operator, so whether or not the expressions are equivalent depends on the language.
|
# ? Aug 8, 2014 00:35 |
|
The reason to do ==false is because it's easier to skim than a single ! Also in C you should do false== because defensive programming.
|
# ? Aug 8, 2014 01:41 |
|
hobbesmaster posted:Also in C you should do false== because defensive programming. Pretty sure our new hire will have to be trained out of doing this.
|
# ? Aug 8, 2014 01:43 |
|
Eh so long as you actually have a standard.
|
# ? Aug 8, 2014 01:43 |
|
In C, you should be compiling with warnings on, including -Wparentheses, preferably as errors (at least in your local build), which will catch silly things like accidentally using assignment instead of equality far more effectively than internalizing dumb rules like always writing false==. There are so very, very many gotchas in C; you might as well let the tools handle the easy ones.
|
# ? Aug 8, 2014 02:39 |
|
Strong Sauce posted:Edit: It seems in node/firefox/chrome any invalid octal number returns the decimal equivalent... which sounds worse than throwing an error. Jesus, it's the worst of both worlds. code:
Edit: Even more simple: code:
HappyHippo fucked around with this message at 02:57 on Aug 8, 2014 |
# ? Aug 8, 2014 02:53 |
|
pokeyman posted:Once upon a time the related if (p == NULL) might've made sense (in C at least), if you couldn't count on NULL being falsy. But I think it's been standardized as 0 for quite some time now. It still makes sense because it makes the code more readable. At least I had to make that a rule because a coworker was doing all sorts of implicit pointer-to-boolean conversions in a way that must have felt so clever but didn't do anything good for readability.
|
# ? Aug 8, 2014 04:20 |
|
Soricidus posted:We were thinking of sticking the code on a spike above the front door as a warning to others. We'd do the same to the perpetrator, but curiously enough he doesn't seem to work for us any more. So what you're saying is that there's no one to be upset if your codebase was mysteriously refactored to sanity.
|
# ? Aug 8, 2014 05:25 |
|
Dr. Stab posted:That's not fair. Using js is cheating. code:
|
# ? Aug 8, 2014 07:09 |
|
pokeyman posted:It is possible, depending on language, that some boolean-ish value needs to be coerced to an actual boolean. For example, in Objective-C (and this anecdote belongs in this thread for one reason or another), the boolean type used to be a typedef'd char, with the values YES and NO defined as 1 and 0. So you could return something like 17 as a boolean, and since it's just C it works when you do if (myBoolValuedSeventeen), but as soon as some joker tried if (myBoolValuedSeventeen == YES) they hosed themselves. The competent library writer would thus make sure they returned YES or NO. I found another fun way to screw up with this in our codebase the other day. code:
|
# ? Aug 8, 2014 08:02 |
|
NFX posted:
Maybe I'm the wrong one but I've always thought that in languages with nullable object types it really makes sense to let you write if (object) and have it coerce to boolean true if it exists and boolean false if it's null. It makes testing for object existence a lot cleaner. The semantic difference between that and if (object == true) also makes sense to me because an (non-null) object reference is a truthy value, but it's not necessarily the literal value true (and it probably actually isn't),, so directly comparing it to true and expecting it to return true for the comparison doesn't make any sense. I guess I just find code:
Look Around You fucked around with this message at 09:21 on Aug 8, 2014 |
# ? Aug 8, 2014 09:19 |
|
NFX posted:
That's the sane behavior...which JS can never ever get.
|
# ? Aug 8, 2014 09:55 |
|
hobbesmaster posted:Also in C you should do false== because defensive programming. What does this mean?
|
# ? Aug 8, 2014 10:01 |
|
QuarkJets posted:What does this mean? If you write if (false = variable), instead of if (false == variable) you'll get an error.
|
# ? Aug 8, 2014 10:03 |
|
Skuto posted:If you write if (false = variable), instead of if (false == variable) you'll get an error. Oh so it's to generate an error in case you leave off the second =, since 'variable = false' would be valid whereas the reverse is not. Good to know
|
# ? Aug 8, 2014 10:46 |
|
Skuto posted:That's the sane behavior...which JS can never ever get. Is there any real reason to support octal literals (as opposed to math functions that handle arbitrary bases) anymore? I know they look neat for some bit twiddling, but hex is always there for that as well.
|
# ? Aug 8, 2014 12:44 |
|
Compilers these days will have a warning like "Did you really want an assignment in an if statement?" But I got in that habit when writing embedded code with a terrible compiler...
|
# ? Aug 8, 2014 12:44 |
|
ulmont posted:Is there any real reason to support octal literals (as opposed to math functions that handle arbitrary bases) anymore? That's what I'd like to know too. Outside of Unix style file permissions, when would you realistically use octal?
|
# ? Aug 8, 2014 13:45 |
|
|
# ? May 17, 2024 02:12 |
|
Volmarias posted:Outside of Unix style file permissions, when would you realistically use octal? Typically, accidentally.
|
# ? Aug 8, 2014 14:18 |