3 ms·
> implicit return combined with “everything is an expression”. You can have one of those, but not both. Hang on, how can you have “everything is an expression”
by chrismorgan 2y ago
> implicit return combined with “everything is an expression”. You can have one of those, but not both.
Hang on, how can you have “everything is an expression” without implicit return? If I’m correctly understanding what you’re talking about, implicit return isn’t actually a thing—it’s just that the function body is an expression too.
(Never dealt with CoffeeScript, but I’ve been writing Rust for over a decade now, and learned to love expression-orientation there.)
- int_19h 2y agoYou do it by making sequential evaluation (i.e. the semicolon, which becomes an operator in "everything is an expression" world) always produce a void result. Then you introduce the notion of terminating evaluation early and yielding a value from the compound expression - this becomes `return` (and other similar constructs like `break` and `continue`).
- chrismorgan 2y agoAh yes, true, true, I had forgotten about the semicolon. Somehow. Yeah, I don’t think I’d like expression-orientation so much without it.