|
Bognar posted:Try this? Yeah I woke up this morning and looked at where it was being called, I couldn't actually trace back where functionSchemas was being declared but it was being called as `this.functionSchemas[blah]` Debugging Chrome Extensions is hard enough but it was just frustrating running into that first bug, which required me to close all my tabs, and then hitting this second bug right before I wanted to sleep. I'm pretty sure I know why this was put in (reuse code for local/sync/managed functions) so the way it was written I think is part of the same discussion (it's bad for this weird error to popup when a developer is trying to use your tools, let alone the obscure error message).
|
# ? Jan 14, 2016 02:23 |
|
|
# ? Jun 10, 2024 04:00 |
|
Found this gem in production today:code:
|
# ? Jan 14, 2016 21:28 |
|
That's a pretty good one.
|
# ? Jan 15, 2016 00:25 |
|
Does ! bind more strongly than >? Is that the problem there?
|
# ? Jan 15, 2016 00:28 |
|
TooMuchAbstraction posted:Does ! bind more strongly than >? Is that the problem there? That's ember.js, right?
|
# ? Jan 15, 2016 00:37 |
|
Strong Sauce posted:Yeah I woke up this morning and looked at where it was being called, I couldn't actually trace back where functionSchemas was being declared but it was being called as `this.functionSchemas[blah]` javascript "this" is dynamically scoped and bound to the caller of the function so the error makes sense in an obtuse way
|
# ? Jan 15, 2016 00:55 |
|
TooMuchAbstraction posted:Does ! bind more strongly than >? Is that the problem there? Sedro posted:Yeah, the block will never execute (assuming length is >= 0). Yes and yes! And in this particular case that number will (famous last words) never anything but a non-zero, positive integer. We are not really looking forward to migrating to ember.js 2.
|
# ? Jan 15, 2016 01:09 |
|
Action Jackson! posted:We are not really looking forward to migrating to ember.js 2.
|
# ? Jan 15, 2016 01:25 |
|
Sedro posted:I just upgraded ours to version 2 last week. I like ember but the 1.12->2.0 transition was not cool. We have a major release coming in like a month so we are going to have to wait a bit until that dies down. So much to do and our feature freeze starts next Friday.
|
# ? Jan 15, 2016 01:27 |
|
What's with those backticks?
|
# ? Jan 15, 2016 03:22 |
|
Suspicious Dish posted:What's with those backticks? Backticks are used for ES6's template strings.
|
# ? Jan 15, 2016 03:31 |
|
Subjunctive posted:No it's not. String literals always have the same type. Except when used in a context that expects a boolean.
|
# ? Jan 15, 2016 08:04 |
|
Oh hey, C++ is broken too!C++ code:
Python code:
|
# ? Jan 15, 2016 08:20 |
|
Using non-boolean values in boolean contexts should be avoided because the results are often surprising.
|
# ? Jan 15, 2016 08:40 |
|
KernelSlanders posted:Except when used in a context that expects a boolean. No, string literals have one type and one type only. Performing different operations with a string as an operand can involve converting that string to another type as one of the steps, but it's the temporary that has a different type. 0 always has the type "number", similarly, though different operations can convert a number to string, boolean, or object. Consider: what type does the literal "horse" have in these two cases? code:
code:
|
# ? Jan 15, 2016 08:59 |
|
Strictly, yes, there's an implicit, anonymous function from string -> boolean being invoked in these cases. But in practice it makes the semantics of the language's typing feel capricious and arbitrary. (This goes for C too, but C somewhat has the various excuses "we hadn't learned yet" and "is just slightly more portable assembly")
|
# ? Jan 15, 2016 09:03 |
|
I agree, there are too many implicit type coercions, and some of them are more confusing than useful. (Witness the confusion in this thread already.) The "truthy"/"falsy" conversions are an artifact of its time, and more so its C heritage. E: C doesn't really have much of a "we didn't know better" excuse, given that Algol itself lacked coercion between integers and booleans, though. Subjunctive fucked around with this message at 11:21 on Jan 15, 2016 |
# ? Jan 15, 2016 10:58 |
|
C technically doesn't have booleans though, so it's less "coercion" and more "everything's a integer".
|
# ? Jan 15, 2016 11:57 |
|
Suspicious Dish posted:And Python! I can't test the C++ code, but what's wrong with those? Or do you just dislike the whole "falsey" or "truthy" thing?
|
# ? Jan 15, 2016 14:41 |
|
SupSuper posted:C technically doesn't have booleans though, so it's less "coercion" and more "everything's a integer". C99 has _Bool, which is a constrained integer -- casting a value to _Bool will always produce 0 or 1, which is not the case for casting to a general purpose integer. C and C++ also test truthiness of pointers differently from integers, since NULL may be a non-zero bit pattern on some architectures.
|
# ? Jan 15, 2016 15:51 |
|
HardDisk posted:I can't test the C++ code, but what's wrong with those? Or do you just dislike the whole "falsey" or "truthy" thing? This guy was saying JS was broken for having this feature — they expected truthiness and comparisons to true to match, for some reason. I was sarcastically pointing it out that it also happens in Good Plang, Python. KernelSlanders posted:Somehow that's both typed and untyped at the same time.
|
# ? Jan 15, 2016 16:54 |
|
I really hate Groovy:code:
|
# ? Jan 15, 2016 17:33 |
|
M31 posted:I really hate Groovy: Isn't that basically the same as Java? Just with an implicit run-time-checked downcast in getB? As scripting languages go, that seems rather mild.
|
# ? Jan 15, 2016 17:55 |
|
JavaScript's handling of truthiness is really interesting because the || and && operators actually return the arguments of whatever type you happen to have provided. That's why people can use || likecode:
Honestly I use truthiness in my JS code...sue me. It's often enough that I want to know that a string is not null and also not empty. Since I write TypeScript, I at least know the goddamn thing is a string.
|
# ? Jan 15, 2016 18:14 |
|
Interpretation of values as booleans is something that lots of languages do subtly differently, and you just have to learn whatever idiom your language uses and adapt to it. I don't think you start getting into objectively wrong territory until you have stuff like "0 apples" evaluating to false because the language helpfully converts to a number for you and then interprets that number as a boolean.
|
# ? Jan 15, 2016 18:21 |
|
TooMuchAbstraction posted:Interpretation of values as booleans is something that lots of languages do subtly differently, and you just have to learn whatever idiom your language uses and adapt to it. I don't think you start getting into objectively wrong territory until you have stuff like "0 apples" evaluating to false because the language helpfully converts to a number for you and then interprets that number as a boolean. "0 but true"
|
# ? Jan 15, 2016 18:28 |
|
fleshweasel posted:JavaScript's handling of truthiness is really interesting because the || and && operators actually return the arguments of whatever type you happen to have provided. That's why people can use || like that's pretty common in dynamically typed languages. Ruby, Python (2.7 at least) and lua all do the same thing. edit: by "the same thing" I mean the binary operators returning the values they were supplied with instead of coercing things to bools. Not having bizzare "truthy/falsy" rules. Zaxxon fucked around with this message at 19:10 on Jan 15, 2016 |
# ? Jan 15, 2016 19:08 |
|
TooMuchAbstraction posted:Interpretation of values as booleans is something that lots of languages do subtly differently, and you just have to learn whatever idiom your language uses and adapt to it. I don't think you start getting into objectively wrong territory until you have stuff like "0 apples" evaluating to false because the language helpfully converts to a number for you and then interprets that number as a boolean. The only more arbitrary thing is "which magic word means 'quit' in this language's REPL?"
|
# ? Jan 15, 2016 19:11 |
|
Zaxxon posted:that's pretty common in dynamically typed languages. Ruby, Python (2.7 at least) and lua all do the same thing. And sh before them all: code:
|
# ? Jan 15, 2016 19:12 |
|
Jsor posted:The only more arbitrary thing is "which magic word means 'quit' in this language's REPL?" Control-D or GTFO
|
# ? Jan 15, 2016 19:37 |
|
gently caress shells that have an ignoreeof option, and gently caress systems that enable it by default.
|
# ? Jan 15, 2016 19:55 |
|
M31 posted:I really hate Groovy: I don't understand what it should be doing instead.
|
# ? Jan 15, 2016 20:35 |
|
So, I had my first encounter with Groovy scripts today, and saw something like this:code:
|
# ? Jan 15, 2016 20:36 |
|
Carbon dioxide posted:So, I had my first encounter with Groovy scripts today, and saw something like this: The += operator evidently appends items to arrays. I've never used Groovy, and that doesn't seem all that strange to me.
|
# ? Jan 15, 2016 20:45 |
|
Fergus Mac Roich posted:I don't understand what it should be doing instead. Theoretically, the type got widened to A when the new B instance was returned from getA(). Therefore it should not be compatible with B returned since it widened. That said, the compiler can probably reasonably determine that the A returned by getA() is actually a B with the information given and do an implicit corrosion back to B. Or it could ignore it, and wait for the runtime cast to B to make sure it is really a B object. Either way is probably more type checking then the average scripting language supports.
|
# ? Jan 15, 2016 20:56 |
|
Groovy is pretty horrible. It's a superset of Java with piles and piles of "helpful" idioms added on top so you're never quite sure what's legal or what any given line of code does, or whether any bareword is a function or a class name or a variable or a type or what. Also you can leave all kinds of things implicit, leading to code which is just incoherent, likecode:
|
# ? Jan 15, 2016 20:59 |
|
Fergus Mac Roich posted:I don't understand what it should be doing instead. I don't know Groovy, or really anything about it, so I'm just guessing at the syntax and type system and could be wrong. But this is what happens (and what I'd expect to happen) with what I *think* is the equivalent code in Scala: code:
|
# ? Jan 15, 2016 21:00 |
|
The dumbest implicit boolean conversion I ever saw was some Python HTML library that treats a node with no children as falsy.
|
# ? Jan 15, 2016 21:11 |
|
Fergus Mac Roich posted:I don't understand what it should be doing instead. Give an error, I don't know. At least give a warning or something. Yes, the only difference between this and Java is essentially implicit versus explicit casting. code:
qntm posted:Groovy is pretty horrible. It's a superset of Java with piles and piles of "helpful" idioms added on top so you're never quite sure what's legal or what any given line of code does, or whether any bareword is a function or a class name or a variable or a type or what. Also you can leave all kinds of things implicit, leading to code which is just incoherent, like code:
M31 fucked around with this message at 21:28 on Jan 15, 2016 |
# ? Jan 15, 2016 21:25 |
|
|
# ? Jun 10, 2024 04:00 |
|
It's called groovy, you should expect that the designers were on drugs.
|
# ? Jan 15, 2016 21:45 |