miniblog.

← Back to all posts
53
It's odd how lazy evaluation is generally seen as a niche design choice, yet the vast majority of languages treat `foo() || bar()` as short-circuiting.

3 Comments

@wilfredh This doesn’t seem out of character: when you think about it the statements that comprise a function in an imperative language also “short circuit” too.
@wilfredh If that doesn’t make sense, I mean the metaphor is that each statement is “lazily evaluated” only once control flow hits it, and it might not ever hit it. I think in a sense C is lazily evaluated too; what it lacks is only referential transparency maybe?
@wilfredh (I know this is a ridiculous take in a way, I just mean the sort of lazy evaluation in short circuiting Boolean operators is the same as elsewhere in the language)