Hello World
Here's the traditional first program:
use(io).
print("Hello World\n")
What do we see here? Here are some of the important points:
- use(io) loads the input/output library. This declares the
print function among other things.
- print("Hello World\n") is a function call. Its one
parameter is a string literal which uses the 'C' style \n
notation for newline.
- The . character is used to separate a declaration (the
use expression) from the body expression (the
print expression).
Compiling and Executing
Note: you need to set some environment variables before using the LARD
tools. Please refer to the overview section of the compilation
tools user guide and the release
notes for the version that you're using for details.
Here's how to compile and execute the Hello World example:
ernie$ lcd hw.l
ernie$ li hw.bcode run
Hello World
Program terminated
ernie$
- lcd compiles the source lard program into a binary
.bcode file.
- li interprets the bcode file. The argument run
to li tells it to run the program immediately.