Tour: Evaluation

Nyarna's keywords sometimes need to evaluate expressions statically. For example, the \func keyword needs to evaluate parameter types (but not default values) statically. This is important because it means that you can't use dynamic values, such as variables and parameter values, in certain contexts.

Whether a certain expression is evaluated statically or dynamically is a local concept and different from the classical difference between compile time and runtime. For example, a function body is a dynamic context, so you can retrieve a parameter's value there. Even if the function is called in a static context, this retrieval is still legal. There is no functionality that is generally not available in any transitively static context.

Nyarna offers some static introspection keywords in the meta library that is part of the standard library. The example shows that we can, for example, iterate over the declared parameters of a function or Record. This is possible because even parameter declarations are first-class values with the type \Location.

Like the rest of the standard library, meta is incomplete and currently mostly a proof-of-concept.