Changeset 187 for trunk/thune/doc
- Timestamp:
- 06/20/06 05:09:27 (3 years ago)
- Files:
-
- 1 modified
-
trunk/thune/doc/UserManual (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/doc/UserManual
r182 r187 110 110 Functions can be defined in two ways: as procedures or as functions. 111 111 112 Procedures are a block of code. 113 114 Functions are procedures with local arguments and variables. These local 115 values are declared in a signature block. When a function is called the 116 arguments are copied from the stack and then dropped. 112 Procedures are simply blocks of code which can be evaluated. Any number of 113 values may be removed from or pushed onto the stack by a procedure. 117 114 118 115 :: … … 120 117 ; Here is a procedure 121 118 ["Hello World" print] proc :hello 119 120 Functions are blocks of code bound to local arguments and variables, and may 121 return either one value or no value. 122 Function arguments are taken from the stack and local variables are 123 initialized to 'none. These local values are declared in a signature block. 124 Functions cannot access values on the stack placed there before the function 125 was invoked. 126 When a function reaches the end or returns, the top stack value (if any 127 has been put there) will be copied to the stack position at the top before 128 the function call (minus any arguments). 129 130 :: 122 131 123 132 ; Here is a function with two arguments and one local variable. 124 133 [arg1 arg2 | var1 -- ret] 125 134 [ 126 ; Function body goes here. 135 ; arg1 & arg2 hold what were the top two items on the stack. 136 ; var1 is none. 137 138 ; TODO: Write this function body. 127 139 ] func :my-function 128 140
