3 ms·
Well, in languages like Scheme and Lisp, expressions are returning a value. But they can also be control structures. For example IF forms are an expression, but
by lispm 7y ago
Well, in languages like Scheme and Lisp, expressions are returning a value. But they can also be control structures. For example IF forms are an expression, but IF is also a control structure:
(if (rocket-engine-running?)
(start-rocket)
(start-engine))
- hzhou321 7y agoWhen expression is not pure value -- they also can be control structures -- the arguments for "everything is an expression" is being defeated, right? A control structure is for defining the path -- control flow. The values in a control structure is a side effect just as the control-flow is a side effect in an expression language. When control flow is the center of logic, won't a control-flow oriented language -- imperative programming -- be more straight forward? In your example, after you started the engine, don't you still need `start-rocket`? The bug sneaks in due to discrepancy that while the syntax is all about values, the semantics is all about flows.
- lispm 7y agoIt gives us as a developer the freedom to decide: do I want control flow, return values or both?