nimp/examples/functions.nimp

23 lines
679 B
Plaintext
Raw Permalink Normal View History

define foo as function with body {
import module io from standard-library.
call io:print with contents as "Hello world".
}
define sumInts as function
taking a as integer,
b as integer,
and returning integer,
with body {
return sum of a and b.
}
define malloc as external function taking size as integer, and returning pointer to void.
define free as external function taking ptr as pointer to void.
define main as function returning integer with body {
call foo.
define x as integer with value of call sumInts with a as 3 and b as 5.
define ptr as pointer to void with value of call malloc with size as 42.
call free with ptr as ptr.
}