Functions

From Mesham
Revision as of 23:37, 3 January 2010 by Polas (talk | contribs) (Created page with '== Syntax == function returntype name[arguments] == Semantics == In a function all arguments are pass by reference (even constants). If the type of argument is a type chain (r…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Syntax

function returntype name[arguments]

Semantics

In a function all arguments are pass by reference (even constants). If the type of argument is a type chain (requires ::) then it should be declared in the body

Example

function Int add[var a:Int,var b:Int]
{
   return a + b;
};

This function takes two integers and will return their sum.

The main function

Returns void, and like C, it can have either 0 arguments or 2. If present, the first argument is number of command line interface parameters passed in, 2nd argument is a String array containing these. Location 0 of string array is the program name.