Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Nathan Wiles edited this page Mar 8, 2023 · 36 revisions

Welcome to the Nala wiki!

This Wiki

This wiki is meant to be an exhaustive reference for Nala's features. For a quick look at how nala works, see the examples directory in the project repo.

Language Overview

Expressions in Nala

Everything is an expression in Nala, including "statements" like assignment operations. Some expressions resolve to values of type Void though, which cannot be assigned.

Void and Capturing Values

Each line in Nala resolves to a value. A function returns the first resolved line it reaches in execution which is not Void. Otherwise, a function always returns the resolved value of the last line it reaches in execution, which can be of type Void.

This may seem like a strange concept, but in practice results in function definitions which are very similar to those in other languages, but with no need for a return keyword.

A non-Void value is considered "captured" when it is converted to a Void value. This happens most commonly as a result of an assignment operation, or the value being passed as an argument to a function which returns Void.

In most cases we do not have to worry about explicitly capturing our values. Sometimes however we will want to capture and swallow a non-Void value so that we do not return before we're ready. For those uncommon situations, the builtin void function has been supplied as a convenience.

Returning early

Note: This is subject to change

For cases where we want to end function execution and return early, the break keyword is provided.

Clone this wiki locally