Syntax
Not all features mentioned here are implemented
The basic language syntax of Loop will be explained here. Only the very basics will be explained here. If the feature has more to it a link to the documentation entry will be provided for more detail.
Entry Point
Every Loop program will start with the file provided when invoking the Loop executable.
For example, this in example.loop
and invoking it with ./loop example.loop
will print "Hello World!"
Standard Input & Output
To read from standard input (stdin) and write to standard output (stdout) Loop provides some easy helpers.
Input
For input you can use the input
function. For example to accept user input without a prompt:
You can also accept user input with a prompt, for example:
Output
It's extremely simple to output to stdout. There are two built-in functions for this.
Allows you to directly print to stdout without a newline.
println
Allows you to print to stdout with an implicit new line.
Variables
In Loop every expression can be assigned to a variable for future reference. This includes things like functions and loops. Declaring a variable is simple and concise.
The most basic feature is assigning an integer to a variable.
It's also possible to assign functions and then call it. Calling a function requires parenthesis. Without them, it will result in the function reference being returned.
Functions
A function is a a simple way to bundle common instructions that might need an alternate input. Defining a function is a simple, for example to create a function that doubles it's input:
Implicit Returns
Most other languages require you to specify the return
keyword to return an expression from a function, however in Loop this is not neccesary. Allowing syntax like the following.
Last updated