Slang/tests/example.sl

26 lines
644 B
Plaintext
Raw Normal View History

2019-08-28 21:24:54 +03:00
# this is a comment
#| and that is a
multiline one. |#
const u32 n = 123123 # n: const u32 (unsigned 32 bit)
const i64 m = 10**18 # m: const i64 (signed 64 bit)
const int z = 2**128 # z: const int (signed unsized)
const auto q = 2**256 # q: const int (signed unsized)
2019-08-28 21:24:54 +03:00
char f(str x) { # f(): char, x: str
auto c = x[1] # c: char
return c # char
2019-08-28 21:24:54 +03:00
}
auto g(str x) { # g(): char, x: str
return x[0] # char
2019-08-28 21:24:54 +03:00
}
int h(int x) = x+1 # h(): int, x: int
2019-08-28 21:24:54 +03:00
main {
stdio.println(h(n), \ # comment here too
2019-08-28 21:24:54 +03:00
f('123asd') + g('32') + 1) #--> «123124 f»
stdio.println(q/z/2**96) #--> «4294967296.0»
2019-08-28 21:24:54 +03:00
}