Difference between revisions of "Functions"
From Mesham
Jump to navigationJump to search (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…') |
|||
Line 19: | Line 19: | ||
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. | 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. | ||
+ | |||
+ | [[Category:Core Mesham]] |
Revision as of 23:38, 3 January 2010
Contents
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.