Blog 2020/7/29
<- previous | index | next ->
This is the simplest example of how to write a Janet project which is a mixture of C and Janet, which results in a single, statically-linked executable.
Run make
to build and test the executable build/baz
.
foo.c
is a Janet native C module which implements a namespace foo
,
which contains one function bar
,
which returns the number 42
.
To build and test this module, run make test-foo
.
You can also start a interactive REPL with this module imported via make repl-foo
(type (foo/bar)
at the prompt).
baz.janet
is a Janet program which imports the foo
module, then prints foo/bar
multiplied by 2.
To build and test the build/baz
statically-linked executable, run make test-baz
, or simply make
.
This is really helpful. Thanks for sharing it!