- Id(x:any) -> type[x]
- safe(x:any) -> any
Id(x:any) -> type[x]
Id(x) returns x. Id has a special behavior when compiled which makes it useful.
The argument is evaluated before being compiled. The intended use is with global
variables: the compiler uses the actual value of the variable instead of a reference
to the global variable. This is very convenient to introduce parameters that are defined
outside the module that is being compiled. This is also used to tell compiler that an
iteration should make explicit use of all iterations rule that may apply to some subclasses
of the set expression being iterated.
safe(x:any) -> any
safe(x) is semantically equivalent to x and is ignored by the interpreter (x = safe(x)).
On the other hand, this tells the compiler that the expression x must be compiled with
the safe setting of the optimizing options. This is useful when a complete program requires
high optimization settings for performance reasons but you still want to ensure that (say)
overflow errors will be detected. A typical use would be :
to implement a bounded multiplication that can be placed in an optimize module.