Changeset 187 for trunk/thune/doc

Show
Ignore:
Timestamp:
06/20/06 05:09:27 (3 years ago)
Author:
krobillard
Message:

Thune - Major improvement to the handling of local function values.
Locals can now be passed to inner functions and caught when returned.
Functions are no longer tied to the thread which created them.

The localArgBlk has been eliminated and locals are now stored on the stack.
To accomodate this, the data stack is now separate from the control stack
and grows upwards. This also means that functions can no longer access the
stack below the function call. A limit of one returned value is in place.

To regain full stack usage, locals could be stored on the control stack.
The only downside would be an extra copy of arguments from the data to
the control stack.

ur_wordCell() is now a function rather than a macro.

uc_do() has been merged into ur_eval() and 'do is now implemented as an opcode.

. & .s now use uc_console_out() rather than dprint.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/doc/UserManual

    r182 r187  
    110110Functions can be defined in two ways: as procedures or as functions. 
    111111 
    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. 
     112Procedures are simply blocks of code which can be evaluated.  Any number of 
     113values may be removed from or pushed onto the stack by a procedure. 
    117114 
    118115:: 
     
    120117    ; Here is a procedure 
    121118    ["Hello World" print] proc :hello 
     119 
     120Functions are blocks of code bound to local arguments and variables, and may 
     121return either one value or no value. 
     122Function arguments are taken from the stack and local variables are 
     123initialized to 'none.  These local values are declared in a signature block. 
     124Functions cannot access values on the stack placed there before the function 
     125was invoked. 
     126When a function reaches the end or returns, the top stack value (if any 
     127has been put there) will be copied to the stack position at the top before 
     128the function call (minus any arguments). 
     129 
     130:: 
    122131 
    123132    ; Here is a function with two arguments and one local variable. 
    124133    [arg1 arg2 | var1 -- ret] 
    125134    [ 
    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. 
    127139    ] func :my-function 
    128140