Hacker News new | ask | show | jobs
by beagle3 2339 days ago
As pointed out in other responses, that's easily down with destructuring and matches in other languages, and even using a regular "case" by building the bits into a number (since the questions have boolean answers in this case).

However, as you yourself hinted, the cost (in C anyway) is giving up the short circuit - which might be expensive, or worse - might have unwanted side effects.

I'm not aware of a common language construct that would switch/match on both A and B, but defer executing B unless its value is actually needed.

1 comments

Haskell would due to lazy evaluation.
Is it guaranteed to be lazy (in this specifically useful way)? Or is it just not guaranteed to be eager?