WTF Bites
-
@greybeard said in WTF Bites:
The two sides of && aren’t arguments into a function.
They can be… if the language supports lazy evaluation. In C, C++, Java, C#, and most other common languages though, nope. ;)
-
@scarlet_manuka said in WTF Bites:
I think @anotherusername's point is that you could have short circuiting with a different order of evaluation, or without a defined order of evaluation.
-
@scarlet_manuka said in WTF Bites:
@zecc I think @anotherusername's point is that you could have short circuiting with a different order of evaluation
Sure, I got it. My point was:
We read left-to-right[citation needed] and conditions are easier to read when you read them in order of general case to specific case[citation needed].
-
@tsaukpaetra said in WTF Bites:
Essentially, all the mathematical operators are illicit
Are those the illegal operations that programs kept performing on old Windows versions?
-
@dkf Oh, agreed, though it'd be interesting to see how far you could get with telling people it's for performance reasons. (Which could even almost be true in some circumstances.) But yes, it doesn't seem like a great idea, which is why I said
It'd be the worst of both worlds[...] Nevertheless, you could design a language that way if you really wanted.
Given the general crappiness of software as seen in this very thread, I wouldn't be at all surprised to find that someone, somewhere, has done this (and not just as part of a joke language).
-
-
@scarlet_manuka said in WTF Bites:
it'd be interesting to see how far you could get with telling people it's for performance reasons
You mean I've got to tell you how bad it is through the medium of interpretive dance?!
-
You mean I've got to tell you how bad it is through the medium of interpretive dance?!
....
Yes, I believe this is now required.
-
-
@anotherusername said in WTF Bites:
@greybeard It could just as easily evaluate the right side first, and then short circuit so that the left side wouldn't be evaluated if the right side is false.
Short circuiting just means that when evaluating
&&
, the second one won't be evaluated if the first one evaluated is false. It doesn't mean that the left side is "first" and the right "second"; it could just as easily be defined to go the other way around.So are you telling me that every time I wrote something like
if( !ptr || ptr->test() )
orif( ptr && ptr->doit() )
I was doing it wrong?I'm telling you that he was saying that -- the guy in the screenshot. And he was most definitely wrong about it for C/C++ (it's defined to evaluate the left side first in those languages), and probably every other programming language ("short circuits, but you have no idea which side the compiler will decide to start with" -- though it's entirely possible to create such a programming language -- would be seriously WTF).
-
@anotherusername said in WTF Bites:
I'm telling you that he was saying that -- the guy in the screenshot.
I absolutely did not get that from your previous post. I still don't.
But it seems we're in agreement here, so...
-
@anotherusername Defining short circuit that way would potentially allow for more compiler optimisations. But most languages prefer well-defined results over performance.
I do expect compilers (especially for C/C++) would reorder the two sides if they can prove there are no side effects.
-
I guess my likes don't count anymore.
This is after a hard refresh, and after I initially liked the video over half an hour ago. It remembers that I liked it but my like counts for nothing apparently.
-
Hi all, this is my picture essay. enjoy:
(these people must have moved to NY from CA)
-
@pie_flavor said in WTF Bites:
https://i.imgur.com/EuVTMQb.png
https://i.imgur.com/8tzW6om.pngThis is completely wrong, right?
Yeah, this is wrong. The whole point of && and || is that they're short-circuiting logical operators. Other people have already pointed out that it is completely idiomatic to rely on it.
However, *puts language lawyer hat on*, this is only true 99.9999...% of the time. Caveat is, if you're completely crazy you can overload operator && / operator || for user-defined types, and then both arguments get evaluated before your user-defined operator gets called.
This is completely crazy, though, breaks every expectation and should never be done, no exceptions. I have no idea why it's allowed.There are many things to complain about in C++. Operator overloading isn't one of them, it's a very useful feature. This, however, should not exist.
Just waiting for someone to out- me and tell me I'm wrong. I did look it up, though.
-
I have no idea why it's allowed.
Because nobody was smart enough to ban it before it got put in a language specification, and nobody's been brave enough to say “well that was a dumb-ass mistake” and take it out. Which is surprising. Is there a codebase out there that overloads
&&
and||
? If so, please, St. Denis of Ritchie, let me never see that code and never have to work with it.
-
Is there a codebase out there that overloads
&&
and||
?Searching...
Apparently UE4 has a plugin that technically does, but doesn't actually do anything different. Looks like it's just adding vegemite?
Pretty sure this doesn't count though.
-
@topspin Actually, in some languages, it's possible to make them short-circuiting as well. In Scala, for instance, it's intended that you define
&&
with a by-name parameter, i.e. a lazily evaluated lambda which doesn't require you to use lambda syntax to pass it.
-
@tsaukpaetra
That code is the Eigen library for linear algebra. It's a prime example of why operator overloading is useful, but I don't get why they'd overload those. Maybe just for completeness?
Also, the snippet doesn't actually show overloaded operator&&, it shows operator(). I think it's what gets executed when expression templates are evaluated, i.e. this is probably the return type of an overloaded operator&& on Array expressions.
-
@tsaukpaetra
That code is the Eigen library for linear algebra. It's a prime example of why operator overloading is useful, but I don't get why they'd overload those. Maybe just for completeness?
Also, the snippet doesn't actually show overloaded operator&&, it shows operator(). I think it's what gets executed when expression templates are evaluated, i.e. this is probably the return type of an overloaded operator&& on Array expressions.Ah. See I have no idea, that's just about the only thing that came up when I searched for
operator&&
across the UE4 source code.
-
The cafeteria's sandwich area's screens are now stuck in a boot loop. They alternate between a black screen, this, and the 'Connecting..' screen from last time.
-
When we switched to a Windows 10 SOE at work, Outlook got stuck in an endless loop: I'd enter my credentials, then Microsoft would send me a text message for 2FA, I'd enter the code in, it would chew on it for a few seconds and then it would go back to the 2FA step again, ending only when I got sick of getting repeated text messages and killed it.
Our IT people had a go at fixing it and I also got suggestions from MS community, but nothing helped until a patch eventually fixed the issue after a few weeks. After that it was fine.... until about a week ago, when the issue suddenly reappeared. The latest patch hasn't helped so once again I am stuck with OWA which is really annoying. (My client-side rules don't work any more, I can't preview CSVs without downloading them, I can only see half a dozen emails at once, etc....)
-
Which is surprising. Is there a codebase out there that overloads && and ||?
The Spirit Parser Framework (formerly Boost.Spirit) seems to overload at least operator||. Not sure about &&; but their thing is pretty much to overload all the operators, so... (The goal is to recreate a EBNF-like syntax in pure C++.)
You probably won't be able to mix Spirit types with other types, so it's a bit less hazardous. (I.e., for
a || b
to be valid, botha
andb
probably need to Spirit types, and the result will not be a boolean.)
-
Spirit Parser Framework
Pfff ... those modern Mediums don't even do their own leg work anymore
-
Which is surprising. Is there a codebase out there that overloads && and ||?
The Spirit Parser Framework (formerly Boost.Spirit) seems to overload at least operator||. Not sure about &&; but their thing is pretty much to overload all the operators, so... (The goal is to recreate a EBNF-like syntax in pure C++.)
You probably won't be able to mix Spirit types with other types, so it's a bit less hazardous. (I.e., for
a || b
to be valid, botha
andb
probably need to Spirit types, and the result will not be a boolean.)Then why not use operator| instead? If it's not short-circuiting this is the better equivalent.
-
Then why not use operator| instead? If it's not short-circuiting this is the better equivalent.
operator| exists as well, and means something different. As said, Spirit overloads most operators...
-
Why? Why would anyone bother to make a rule like this? It makes text selection almost invisible, at least on my screen:
-
@anonymous234 I can read the selection perfectly fine though, at least if it was "components required for .... e an excellent food sou".
-
This is a good one, illegal (depending on jurisdiction) anti-piracy measures. Oops:
(I thought it belonged here rather than IONT because it is definitely a WTF).
-
@jbert I can only see it at certain angles. Granted, my LCD screen is not the best one, but still, it's a contrast ratio of only 1.07:1 according to the contrast checker.
-
Ya know, maybe this ain't the best name for an online casino game...
-
@pie_flavor said in WTF Bites:
https://i.imgur.com/EuVTMQb.png
https://i.imgur.com/8tzW6om.pngThis is completely wrong, right?
Yeah, this is wrong. The whole point of && and || is that they're short-circuiting logical operators. Other people have already pointed out that it is completely idiomatic to rely on it.
However, *puts language lawyer hat on*, this is only true 99.9999...% of the time. Caveat is, if you're completely crazy you can overload operator && / operator || for user-defined types, and then both arguments get evaluated before your user-defined operator gets called.
This is completely crazy, though, breaks every expectation and should never be done, no exceptions. I have no idea why it's allowed.There are many things to complain about in C++. Operator overloading isn't one of them, it's a very useful feature. This, however, should not exist.
Just waiting for someone to out- me and tell me I'm wrong. I did look it up, though.
Seriously? Wow. It'd make sense if those were defined to always inline and the arguments would only be evaluated at the point you actually try to access them in the operator function. Or a way to create a bool accessor function instead of overloading the
&&
operator, so thata && b
would turn into(bool) a && (bool) b
-- then you could at least have it short circuit if you programmed it to do so...
-
@scarlet_manuka said in WTF Bites:
My client-side rules don't work any more
I'm on Windows 7 and an Outlook update broke some of mine. Appears they've removed the "execute script" option.
-
@anonymous234 said in WTF Bites:
Why? Why would anyone bother to make a rule like this? It makes text selection almost invisible, at least on my screen:
That looks about the same as the unread notification highlight style color that the default theme here uses.
-
@anotherusername said in WTF Bites:
Or a way to create a bool accessor function
That's possible by implementing
operator bool()
, if I recall correctly.
-
@zecc then it should be possible (by adding
operator bool()
and notoperator&&
) to force it to convert both sides to bool and use the built-in&&
operator, which does short circuit.If you're doing something in
&&
that doesn't allow you to naively consider the truthiness of each side independently, then your&&
probably couldn't short circuit anyway.
-
@anotherusername Yes, I concur 100%.
operator bool
already does what you need and any logic that could possibly allow to short-circuit would be expressible like this, already.operator &&
is the wrong solution.
-
@scarlet_manuka said in WTF Bites:
I am stuck with OWA which is really annoying
Outlook's Worse Access ?
-
@timebandit said in WTF Bites:
Outlook's Worse Access
Overwatch Wiki Association
Opossum Weather Announcer
Open Wombat API
-
@cursorkeys said in WTF Bites:
This is a good one, illegal (depending on jurisdiction) anti-piracy measures. Oops:
(I thought it belonged here rather than IONT because it is definitely a WTF).
What? Even pirates have rights. What kind of retard thinks they can get away with software that steals login details from the Chrome cache?
-
@pie_flavor I hope the EU hits them with the new data privacy laws the EU will enact in May (as well as criminal charges).
Basically, if you're found wanting in regards to those laws, you'll be hit with a fine of 4% of your revenue (minimum of 50,000€, maximum 20,000,000€).
-
@timebandit said in WTF Bites:
@scarlet_manuka said in WTF Bites:
I am stuck with OWA which is really annoying
Outlook's Worse Access ?
Sounds about right.
-
@cursorkeys said in WTF Bites:
This is a good one, illegal (depending on jurisdiction) anti-piracy measures. Oops:
(I thought it belonged here rather than IONT because it is definitely a WTF).
Oh wow. I remember seeing that and thinking I'd read it later. It's later now, and I read it. Just wow.
I'm not sure if I can think of a jurisdiction where that wouldn't be very illegal. I hope they burn.
-
-
@greybeard said in WTF Bites:
And everyone knows that internal CAs should expire in early 2038.
So that's 2 × 3650 = 7300 days?
+1 for each leap day in: 2020, 2024, 2028, 2032, 2036
7300+5 = 7305 days
-
My uncle could use that. Seriously.
-
Popupception
-
@cursorkeys said in WTF Bites:
This is a good one, illegal (depending on jurisdiction) anti-piracy measures. Oops:
(I thought it belonged here rather than IONT because it is definitely a WTF).
These guys SHOULD get sued out of existence.
-
@bb36e "Looks like you might be in Canada. But are you really? Be the first to know!"
-
@pie_flavor I hope the EU hits them with the new data privacy laws the EU will enact in May (as well as criminal charges).
Basically, if you're found wanting in regards to those laws, you'll be hit with a fine of 4% of your revenue (minimum of 50,000€, maximum 20,000,000€).
I understand your point, but I hope they won’t hit them with a law that’s not in the effect as of date the crime was committed.