|
Attempts to make programming "work" just like written english are the worst. How can someone experienced enough to design and implement their own programming language not see how that's a terrible idea?
|
# ? Jan 15, 2016 21:47 |
|
|
# ? Jun 10, 2024 00:02 |
|
vOv posted:The dumbest implicit boolean conversion I ever saw was some Python HTML library that treats a node with no children as falsy. HappyHippo posted:Attempts to make programming "work" just like written english are the worst. How can someone experienced enough to design and implement their own programming language not see how that's a terrible idea? SQL does OK. Opinions vary about AppleScript, but HyperCard is held in generally high regard.
|
# ? Jan 15, 2016 21:51 |
|
vOv posted:The dumbest implicit boolean conversion I ever saw was some Python HTML library that treats a node with no children as falsy. That sounds like a fairly standard "empty containers are falsy" kind of thing. Though if nodes are anything beyond merely containers then it becomes more problematic.
|
# ? Jan 15, 2016 21:57 |
|
Subjunctive posted: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. Yeah, but that being a C99 extension matters. They didn't have that in the initial design, and you can't retroactively change it. Subjunctive posted:C and C++ also test truthiness of pointers differently from integers, since NULL may be a non-zero bit pattern on some architectures. That's not "differently from integers". The integer rule is not comparison against a zero bit pattern, it's comparison against 0, which would matter on a target using a sign-magnitude representation. It's also an important difference for floats.
|
# ? Jan 15, 2016 22:11 |
|
vOv posted:The dumbest implicit boolean conversion I ever saw was some Python HTML library that treats a node with no children as falsy. to be honest, I don't view that as significantly worse than treating [], "", and 0 as falsy
|
# ? Jan 15, 2016 22:27 |
|
TooMuchAbstraction posted:That sounds like a fairly standard "empty containers are falsy" kind of thing. Though if nodes are anything beyond merely containers then it becomes more problematic. Steve French posted:to be honest, I don't view that as significantly worse than treating [], "", and 0 as falsy The problem is that empty HTML nodes are very common for stuff like <img>, <meta>, and <script>. Although apparently they fixed it at some point.
|
# ? Jan 15, 2016 22:30 |
|
vOv posted:The problem is that empty HTML nodes are very common for stuff like <img>, <meta>, and <script>. Although apparently they fixed it at some point. turns out that empty arrays, empty strings, and the number zero are also pretty common!
|
# ? Jan 15, 2016 22:33 |
|
M31 posted: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. OK, yeah, but that's way weirder than your original example. An implicit cast on return is pretty normal and predictable. An implicit cast when you call a method through a reference is much less so.
|
# ? Jan 15, 2016 22:36 |
|
M31 posted: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. I see what you're saying. This example is downright bizarre. Steve French posted:to be honest, I don't view that as significantly worse than treating [], "", and 0 as falsy A node in a tree can still have meaning beyond its having children, though.
|
# ? Jan 15, 2016 22:44 |
|
rjmccall posted:That's not "differently from integers". The integer rule is not comparison against a zero bit pattern, it's comparison against 0, which would matter on a target using a sign-magnitude representation. It's also an important difference for floats. My point was that it's not the case that "everything is an integer" for purposes of truthiness, because you can have false values for which the same bit pattern interpreted as an integer would be considered true (not equal to 0).
|
# ? Jan 15, 2016 22:49 |
|
Fergus Mac Roich posted:A node in a tree can still have meaning beyond its having children, though. Sure, it's worse, my point is just that I think falsiness is generally a bad thing. The only things that should be considered false are false, and nil/null, if you absolutely must have nil/null as a thing.
|
# ? Jan 15, 2016 22:49 |
|
Everything except true and false should result in a run time error.
|
# ? Jan 15, 2016 23:24 |
|
sarehu posted:Everything except true and false should result in a run time error. In boolean contexts, or just generally?
|
# ? Jan 16, 2016 00:28 |
|
1 + 2 error: 1 is not true or false 2 error: 2 is not true or false true == true error: == is not true or false true error: is not the true true
|
# ? Jan 16, 2016 01:12 |
|
sarehu posted:Everything except true and false should result in a run time error. Everything except the Boolean type as a conditional should result in a compile-time error.
|
# ? Jan 16, 2016 01:25 |
|
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 Zaxxon posted:that's pretty common in dynamically typed languages. Ruby, Python (2.7 at least) and lua all do the same thing. Note C#'s weird way of doing it. It returns neither the value on either side nor a Boolean. code:
|
# ? Jan 16, 2016 01:46 |
|
Dylan16807 posted:Note C#'s weird way of doing it. It returns neither the value on either side nor a Boolean. C# lets you indirectly overload || and && via true and false "operators", which are implicit conversions from your user-defined type to boolean
|
# ? Jan 16, 2016 02:41 |
|
Steve French posted:to be honest, I don't view that as significantly worse than treating [], "", and 0 as falsy Would you say that treating 0 as truthy is worse than treating it as falsey, though?
|
# ? Jan 16, 2016 03:07 |
|
I want my language to spit out 500 word essays about how it feels when evaluating my expression and justify relying on a gut feeling to produce the result.
|
# ? Jan 16, 2016 03:13 |
|
xzzy posted:I want my language to spit out 500 word essays about how it feels when evaluating my expression and justify relying on a gut feeling to produce the result. Sounds like a possible INTERCAL extension.
|
# ? Jan 16, 2016 03:24 |
|
Sedro posted:I don't get it. Let's say you implement the true and false operators on your custom number type T. T(6) && T(10) is not true or false or T(6) or T(10). It's T(2). http://csharppad.com/gist/07f03054562c64e2e4ac Dylan16807 fucked around with this message at 03:28 on Jan 16, 2016 |
# ? Jan 16, 2016 03:25 |
|
ErIog posted:Would you say that treating 0 as truthy is worse than treating it as falsey, though? No. In the pissing match between Ruby and Python, this is one of the things that I most firmly believe Ruby gets more right.
|
# ? Jan 16, 2016 04:13 |
|
Axiem posted:Everything except the Boolean type as a conditional should result in a compile-time error. Everything except Subtract And Branch If Negative should result in a compile-time error
|
# ? Jan 16, 2016 05:12 |
|
Everything except the unary one tape turing machine should be banned.
|
# ? Jan 16, 2016 05:16 |
|
Jsor posted:Everything except the unary one tape turing machine should be banned. Then you'll just have people arguing that those are technically linear bounded automata, because a turing machine technically has an infinite tape.
|
# ? Jan 16, 2016 06:08 |
|
xzzy posted:I want my language to spit out 500 word essays about how it feels when evaluating my expression and justify relying on a gut feeling to produce the result. Compiler all sending a note to your grandma about how disappointed it is in you.
|
# ? Jan 16, 2016 06:45 |
|
Subjunctive posted:"0 but true" Perl is the best language ever just because of the glorious poo poo you can pull. code:
|
# ? Jan 16, 2016 06:53 |
|
Pavlov posted:Then you'll just have people arguing that those are technically linear bounded automata, because a turing machine technically has an infinite tape. Just glue the ends together and it's practically infinite.
|
# ? Jan 16, 2016 09:25 |
|
xzzy posted:I want my language to spit out 500 word essays about how it feels when evaluating my expression Let me tell you about C++ templates.
|
# ? Jan 16, 2016 11:18 |
|
qntm posted:Let me tell you about C++ templates. It's not a real template error unless it doesn't fit in working memory
|
# ? Jan 16, 2016 19:43 |
|
code:
"I know what I'm doing."
|
# ? Jan 16, 2016 19:49 |
|
Wikipedia's tech is poo poo. Watch as a PNG file magically returns a application/x-www-form-urlencoded Content-Type! https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Cholesterol.svg/200px-Cholesterol.svg.png
|
# ? Jan 16, 2016 20:23 |
|
code:
|
# ? Jan 17, 2016 13:46 |
|
iSurrender posted:
?? has existed in C# for a good while prior to C# 6. I think you may be mixing it up with the ?. operator
|
# ? Jan 17, 2016 14:54 |
|
iSurrender posted:
?? Has been around for years C# 6 introduced ?. for shorthand null method chaining (bind with the arg being the lhs in the maybe monad) But you could emulate it with a suitable class via linq
|
# ? Jan 17, 2016 14:55 |
|
Dumlefudge posted:?? has existed in C# for a good while prior to C# 6. I think you may be mixing it up with the ?. operator Yep, my bad.
|
# ? Jan 17, 2016 15:08 |
|
iSurrender posted:
They should have unintroduced null instead.
|
# ? Jan 17, 2016 18:37 |
|
https://github.com/samshadwell/TrumpScript/blob/master/test/test_files/fizz_buzz.txtcode:
|
# ? Jan 18, 2016 17:42 |
|
Suspicious Dish posted:Wikipedia's tech is poo poo. Watch as a PNG file magically returns a application/x-www-form-urlencoded Content-Type! Their image viewer poo poo is so obviously some incompetent web astronaut's weird obsession. "Lets make every image format work on every browser" is a fine sentiment but all they've done is make them all half-work, including the ones that already worked just fine. It's also pointless now that there are only three major renderers, all of which have good support for most common formats.
|
# ? Jan 18, 2016 20:11 |
|
|
# ? Jun 10, 2024 00:02 |
|
Found this in a homework friend needed help with.code:
|
# ? Jan 18, 2016 23:43 |