Skip to content

Functions and Macros

Roger Johansson edited this page Jul 20, 2015 · 2 revisions

Standard function declaration:

hello := func(who)
{
   print ('hello ' + who)
}

Or written as a lambda expression:

hello := who => print ('hello ' + who)

Switch/Case macro:

switch :=  func(exp, body.ref)
{
    matched = false;
    case := func (value, caseBody.ref)
    {   
        if (exp == value)
        {
            caseBody();
            matched = true;
        }
    }
    default := func (defaultBody.ref)
    {
        if (matched == false)
        {
            defaultBody();
        }
    }
    body();
}
Clone this wiki locally