Skip to content
Michael Ermishin edited this page Feb 26, 2018 · 1 revision

Welcome to the FBL wiki!

Getting started

Writing your first code

set "main" ([ args ]
    print "Hello, world!"
)

Here new variable main is defined with a value of type function.
It is called automatically by the interpreter when you run the code.

Currently we have only one expression to execute.
print takes 1 argument and just writes it to the console.

But what if you want to perform multiple actions one after another?
To separate them the special symbol : is used.

: set "main" ([ args ]
    : print "Welcome to the 'hello world printer' program."
    : print "It writes the magical text to your screen! *(shock)*"
    : print "Hello, world!"
)

Here we added : to the beginning of each statement.
It is not necessary to write the first colon, because nothing precedes it.
However this way of expressions partition is more convenient and less error prone.

REPL. Doing some math

Let's start with something simple. User enters two numbers and we are performing multiple actions:

addition
subtraction
multiplication

Let's start from using built-in function called input. It takes the target type we want to read.

: set "main" ([ args ]
  : set "a" (input number)
  : set "b" (input number)
)

Here we enclosed input number with braces () because of the execution order.
We don't want to set our variable to input and then do some nonsense stuff with it.

But number is not the only type you can read from the input. You can specify:

string
int
number

int does almost the same thing as number do, but it's output is the whole number (integer).

Finally we use built-in math functions to calculate the result

: set "main" ([ args ]
    : set "a" (input number)
    : set "b" (input number)
    : print (+ a b)
    : print (- a b)
    : print (* a b)
)

Now our little program is done!

Additional resourses

If you want to learn more visit the following pages:

Clone this wiki locally