Sure, syntactically it's an expression-based language, but some of those are expressions in syntax only. If a function terminates in nil, what exactly did it compute? And what exactly is the point of all but the last argument to a `progn`?
An expression that is evaluated for the side effects, not the result value, is a statement in every way that matters.
(Haskell has a stronger claim because it actually captures the side effects as a value.)
I think the general consensus is that expressions evaluate to values in unexceptional situations, full stop. Whether they have side effects is immaterial. Whether the value returned is useful or not is also immaterial. Perhaps your examples weren't the best, since both setf and loop evaluate to values which are often useful.
This isn't just Lisp. For example, the C99 specification explicitly declares that all function calls are expressions, even if they return void.
Wikipedia also defines an expression (vs. statement) unambiguously as "a syntactic entity in a programming language that may be evaluated to determine its value.... Expression is often contrasted with statement—a syntactic entity that has no value (an instruction)."
nil.
The fact that you can syntactically put loops and ifs in place of expressions is what makes them expressions
One would think you could just `(defun fun () nil)`.
I have the impression that you think that an expression is a way to compute a value, while I would posit that an expressions are a method of combining values.
Not really an expression:
a0 = 1;
a1 = f(2);
if (a0 < a1){
a2 = getInput();
} else {
a2 = 3;
}
result = a0 + a1 + a2;
More of an expression: result = 1 + f(2) + (a0 < a1 ? getInput() : 3);No. The expression before evaluation (i.e. as it's written) is a question/query/ask, after a successful evaluation you get a value - an answer. In case when the evaluation failed, you get either a compilation/parsing error, runtime error/exception, crash, infinite loop/no return, or undefined behavior.
--
- Commands and Queries (as in CQS[1] and CQRS[2])
- Wishes and Asks (it's a wish b/c unlike command it can be rejected, and for the same reason it's an ask and not a query - i.e. "you may ask, but it doesn't mean I'll answer").
- Truth or dare?[3] (Dares and Truth-es ;)
--
[1] https://en.wikipedia.org/wiki/Command%E2%80%93query_separati...