Open chsasank opened 3 months ago
Since we are borrowing C semantics, all expressions (including those that aren't formatted as lists) are valid statements.
Thus, the following while
statement is valid:
(while #t ; Infinite loop
0) ; Placeholder statement
The if isinstance(stmt, list)
is in place to handle the case of a non-list expression (e.g. literal, variable reference) being used as a statement. The alternative would be to have the same check in every is_*_stmt
function, in which case it would fall through to return self.gen_expr(stmt).instructions
.
Admittedly, though, none of our testcases use this structure.
https://github.com/chsasank/llama.lisp/blob/c79daf7a267461f5ebf8fef57d61321192a6127c/src/backend/c-lisp.py#L137
here, the
if isinstance(stmt, list)
andself.gen_expr(stmt)[0]
are redundant. I think we can remove them.