Interpreter
Interpreter copied to clipboard
Implement statements-as-expressions
Statements-as-expressions allows some statements (like if/match) to be used as expressions that return a value. This could easily be done by simply converting these to expressions and using Statement.Expression, however that requires hardcoding a list of allowed expressions. There are two open questions related to this:
- Figure out an effective way to distinguish which
Ast/Irclasses are usable as statements/expressions without having to hardcode a list. This has been tried previously with interfaces, which seems manageable but is a little messy with Kotlin. - Figure out if/how wrapped classes (like
Statement.Expression) can be removed. The current belief is that some wrapped classes likeStatement.Componentmay be necessary for the Analyzer to handle validation; if so there may not be a compelling reason to redesign things here.