Preprocessor statements

set statement

The set statement, sets a preprocessor variable to a value. The values of preprocessor variables are not bound to types.

%set VERSION 0.7.1%
%set APPLICATION_NAME My Application%

Some variables are set by the Hades interpreter.

if-else if-fi statement

The if-elif-fi block has a couple special commands to compare values to each other.

with os from std:os
with console from std:io

var listCommand

%if eq OS Windows%
listCommand = "dir"
%else if eq OS Linux%
listCommand = "ls"
%else%
console.out("OS not recognized!")
os.exit(-1)
&fi%

%if ge OS_VERSION 1803%
os.exec("wslpath 'c:\users'")
%fi%

os.exec(listCommand)

import statement

The import statement copies the content of the specified file and pastes it into the source code (works recursively).

function.hd

func print(...a)
    for(var arg in a)
        console.out(arg)
    end
end

classDef.hd

class printer
%import function.hd%
end

main.hd

with console from std:io

%import classDef.hd%

printer().print("Hello","world")

Result

main.hd is being converted to:

with console from std:io

class printer
    func print(...a)
        for(var arg in a)
            console.out(arg)
        end
    end
end

printer().print("Hello","world")

Last updated