You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, one downside is that in expressions like 2+g() suddenly some Expr nodes (the former Stmt nodes) would not be allowed. That is not very consistent. Also, many times we accept an expression, say for dimensions, indexing, or loop begin/end, etc. We would have to add verify() checks for each case that it is not a former Stmt node, and handle the case if it is (or assert, etc.).
Here is an alternative solution. Let's add an Expr(expr expression) node into stmt. This is exactly what Python does at the AST level. Then a list of statements can contain an Expr node, and it tells the backend that one should drop the result. Currently we use the Assignment() node with a dummy variable for that. So an Expr node is an iterative improvement of this idea. It cleans things up, and either it will be good enough, or if not, we can still unify Expr and Stmt later.
Currently in Python we can have code as follows:
Which will print "Something".
This is currently represented in the compiler roughly as:
If we only have expressions, then the above will not be an assignment, but just the expression (
2+g()
org()
) and we will not use the result.The text was updated successfully, but these errors were encountered: