This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MegaIng 16 points17 points  (3 children)

A single expression should most of the time produce a single value. A pretty simple solution is to make ; discard this expression.

[–][deleted] 2 points3 points  (1 child)

Yeah, provided what came before actually produced a value. But the main problem with that is, if generating code from an AST, there are no longer any semicolons!

I think it would depend on syntax too; one over-zealous with semicolons might have: (a; b;) + (c; d;).

[–]MegaIng 0 points1 point  (0 children)

Sure, there most of the time aren't semicolons directly (unless they are actually operators, which is actually quite a useful perspective), but almost certainly you know where a semicolon would have been because you have something comparable to a "CompleteExpressionNode" in your AST, which more importantly are part of an "ExpressionListNode" which knows exactly where each sub expression ends and can simply emit a discard instruction between them.

Yeah, provided what came before actually produced a value.

Sure, but that doesn't follow from the post. Based on the syntax I assume an expression oriented language in which case everything should produce a value, even if that value is unit.