|
hoshi-lang dev
Yet another programming language
|
Hoshi-lang has a simple conditional compilation feature that works like a macro system. This allows you to include or exclude code based on flags passed to the compiler.
The syntax for a macro is a double-bracketed expression:
<key>: The name of the macro.<operator>: One of ==, !=, <, >, <=, >=.<value>: The value to compare against.If the condition is true, the code immediately following the macro will be included in the compilation. Otherwise, it will be ignored.
Hoshi-lang provides the following pre-defined macros:
platform: The operating system the compiler is running on ("darwin", "linux", or "win32").arch: The architecture the compiler is running on (e.g., "x86_64", "arm64").hoshi_feature_version: The version of the Hoshi-lang language.hoshi_lang_commit: The git commit hash of the Hoshi-lang compiler.You can define your own macros using the -D or --define flag when compiling:
In this example, the appropriate puts call will be included based on the operating system the code is compiled on.