top of page

Notable features

Comparison chains  
​

Beaver creates a chain for non-associative comparison operators  (<, >, == etc.) and checks the condition pairwise.

​

> 0 == 0 == 0

True

​

> 1 == 1 == 2

False 

​

Implicit multiplication
​

You can multiply a variable by a number without using the * operator 

> x = 5

> 2x

10 

​

Custom Operators
​

Beaver allows programmer to define their own operators using the oper keyword.

​

oper <operator-string> <precedence> <associativity> <function>

#EVAL#

​

The associativity can be given as left, right or none.

The #EVAL# flag forces evaluation up to this point so that the remaining code is parsed with this new operator in the database.

For example a new operator to concatenate two tuples

​

> oper "+++" 5 left ((a, b) (c, d) -> (a, b, c, d})

 

> (1, 2) +++ (3, 4)

(1, 2, 3, 4)

​

Type system modes
​

By default Beaver allows dynamically types variables. By writing this comment #STATIC-MODE# on a separate line variables can only be assigned values of the same type as inferred during its declaration.

Instead if the programmer writes #FUNCTIONAL-MODE# then variables cannot be re-assigned.

​

Advanced switch statement
​

The switch statement uses pattern matching rather than just equality.

​

switch x (

    1 -> print 1

    2 -> print 2

    3 => print 3

    4 -> print 4

 

The -> arrow allows the statement to continue whereas the => signals the exit from the statement.

​

Operator Overloading
​

Operators can be overloaded on objects by defining certain methods.

​

def add 

def sub

def subfrom

def mul

def div

def raise

def power

def equals

def greaterThan

def lessThan

bottom of page