-
Notifications
You must be signed in to change notification settings - Fork 6
Preprocessor Functions
VSL has a diet preprocessor that you can access using functions prefixed with #
.
Internally replaced with a string which is the name of the type that <expression>
resolved to. This returns the static type not the dynamic type. Meaning if you have an instance of String
cast as an Equatable
, it will return Equatable
. If you want specific names you'll need to use Reflect<Equatable>(instanceType: myEquatableValue).typeName
which will generate RTTI for all types.
Example:
print(#typeName(1)) // Resolves to 'Int32'
Evaluates to a tuple with the signature:
(source: String, line: Int)
where line
is a one-indexed number indicating the line number that the preprocessor directive was found. The source
is a string which represents the stream which the preprocessor token was found. This is likely the source file but maybe another token such as <stdin>
.
Example:
// example.vsl
print(#position.source + ":" + #position.line)
$ vsl < example.vsl
<stdin>:2
- Introduction
- Installation
- VSL By Example
- Usage
- WASM (WebAssembly)
- The Basics
- Your First Program
- Syntax
- Concepts
- Modules
- Advanced Details
- Interop
- VSL Development
- Common Errors