Sempiler provides a construct to express optional types (in source languages that do not have them inherently) for targeting platforms that use them.

Symbol Usage Notes
type opt<T> = T Symbolic optional construct  

We use opt like other fakeywords, except it is aliased to T rather than undefined.

A goal of the Sempiler design is to have code feel natural to write in the source language, whilst being valid for the target context.

By aliasing opt<T> to T we can assign T values directly to an optional datum as if it were being boxed and unboxed automatically.


If you are sempiling to a target platform that has strict optionality (eg. Swift) you must observe the following:


To unwrap an optional we can use a non-null assertion. In TypeScript we use the ! postfix unary operator.