Tutorial¶
This tutorial walks through stone from a first program to lists, functions, and input. If you know Python, most of it will look familiar: the differences are mostly fewer Shift presses and a type checker that runs before your program does.
Every program in this tutorial is part of stone’s test suite, which runs it under both the interpreter and the compiler and checks that each prints exactly the output shown.
Your first program¶
Save this as hello.st:
print("hello, world")
stone gives you three ways to handle it:
stone run hello.st # interpret it
stone build hello.st -o hello && ./hello # compile a native executable
stone check hello.st # only look for errors
stone hello.st is shorthand for stone run hello.st. Either way, it prints:
hello, world
Blocks and indentation¶
Like Python, stone groups statements by indentation. A line that opens a block ends in ;
where Python would use :, and the indented lines after it are the block:
if 2 > 1;
print("math still works")
A block with a single statement can also follow the ; on the same line, as in
if done; break. Comments start with // and run to the end of the line.
Next, Values and types.