empirical-soft / empirical-lang

A language for time-series analysis
https://www.empirical-soft.com/
Other
168 stars 13 forks source link

Compile-time function evaluation #44

Closed chrisaycock closed 4 years ago

chrisaycock commented 4 years ago

As part of #23, we need to evaluate an expression at compile time. With the computation mode (#26), we know when building ahead of time (AOT) is possible.

let x = 7 + 5

General-purpose CTFE will leave results in VVM, though literal results (eg., integers or strings) are brought back to Sema. This is necessary for templates and macros.

let declarations and return statements will carry the evaluated literal in the HIR. var cannot have CTFE because it can always be reassigned.

User-defined types and functions must be sent to VVM ahead of time.