Fakeywords augment the lexicon of the source language, in order to represent concepts present in the target context.
For example, TypeScript does not have an
inline keyword but we can use the fakeyword equivalent to represent the same concept. When that source code is sempiled to a target platform that does have function inlining, the emitter will annotate the function accordingly.
In TypeScript we can leverage the union type as a container for fakeywords, along with the actual type annotation for the associated source expression.
We alias the fakeyword (eg.
undefined. That way it’s usage will have no influence on the type checker as TypeScript ignores undefined types.
||Typical fakeyword type definition|
Therefore the union will collapse to represent just the actual type of the associated source expression.
By now you will probably know that one of the core concept in sempiling is NOT to abstract away the target platform.
Accordingly, different target contexts will provide different fakeywords for you to leverage in your source code. For example, Swift has
required which C++ does not.
The following table is for reference:
||Function inlining||Type annotation on function declaration return type|
||Used on methods and constructors that are overrides|
Plus the intrinsic data types for your target platform.