blob: 6f87160110834583f0a9cf17adbd71a12ce666ec (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
[comments in square brackets]
[preprocessor directives]
#INCLUDE 'math.halk'; [looks for a 'math' file in cwd, then ~/halk/include]
#INCLUDE 'io' AS ''; [bring everything in 'io' into global scope]
let.hello -> 'hello, '; [variables must be given a value at declaration]
let.PI => math/PI; [header namespaces are accessed with a '/']
[constants are denoted with a '=>']
fn.greeting.to -> { ['fn' only expects 1 argument, so no grouping of arguments is necessary]
let.message -> str.cat.(hello,to); [parens can be used to make calls to multi-argument
functions more clear]
stdo.message; [since 'io' was brought into global scope, we
don't need to (and, in fact, cannot) prefix it
with a namespace]
};
fn.sum_all._ -> { [variadic functions are possible with the reserved '_' argument,
which is treated as an array]
return.foldl.+,0,_;
};
fn.main -> { [where our code will begin executing]
greeting.[comments can be placed *anywhere*]"world.";
exit.0; [exit with code 0]
};
|