My favorites | Sign in
Logo
                
Search
for
Updated Dec 05, 2008 by admiwi
Labels: Featured, Phase-Implementation
Documentation  
How Foom Works...

Foom

Foom is a dynamically typed, lazily interpreted language. Most statement are terminated with a ; with the exception of for and if/else. For examples, please take a look at the tests directory in the source.

Datatypes

There are five basic types in Foom:

Variables

Variables are declared with a primary data type as such:

str s;
int i = 10;
list l = [2, i, 39];
func f;
f = { args[1]; };

Currently, one declaration per statement.

Comments

Currently nonexistent. Planning on # to ignore rest of line. Maybe ## for blocks.

Functions

Functions are declared using the func keyword, setting the variable to a block. The block is only evaluated when the function is called so using the function variable name in the block, thus a recursive function, will behave as expected. Arguments to the function are passed in as list called args. All variables are currently passed by reference. The last statement in a function is the function's return value. Functions are assignment statements thus must end with a ;. (Per Bug 1, all functions require arguments.)

The following function takes three arguments: a list L, integer A, and integer B. It swaps position A in list L with position B and returns L at the end.

func swap = {
  list l = args[0];
  int t = l[args[1]];
  l[args[1]] = l[args[2]];
  l[args[2]] = t;
  l;
};

Libraries

Currently, only one library exists and it is imported automatically.

sys

sys has two fuctions:

Hosted by Google Code