home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / MorphOS / Epic4_mos / share / epic / help / 5_programming / bless < prev    next >
Encoding:
Text File  |  2002-10-28  |  2.0 KB  |  50 lines

  1. Synopsis:
  2.    bless
  3.  
  4. Technical:
  5.    The bless command allows an asynchronous atomic scope (eg, inside an
  6.    on), to gain access to the local variables of an enclosing scope.
  7.    Care must be taken to make sure that this command is only executed in a
  8.    situation where this is an enclosing scope to gain access to.
  9.  
  10.    Normally when an "atomic scope" is invoked (an "atomic scope" is by
  11.    definition an alias (or alias function) invocation or any asynchronous
  12.    event (an on, a timer, a wait -cmd, a queue)), a new 
  13.    stack frame is created and access to any local variables in previous
  14.    stack frames is not allowed (because there is no guarantee just what 
  15.    exactly is in the scope below us, so accessing their variables could be
  16.    disastrous.)  However, in some cases, there is reasonable assurance that
  17.    an atomic asynchronous scope will in fact be executed synchronously, and 
  18.    that the previous stack is well-known, and that access to the local
  19.    variables in that stack is desirable.  The semantics of this are straight-
  20.    forward.  The enclosing (outer) scope must take some action to ensure that
  21.    it will not "end", thus ending its stack frame, until the enclosed (inner)
  22.    scope is done manipulating its local variables.  This is most often done
  23.    by a wait command in the enclosing scope.  The enclosed scope then 
  24.    would do a bless, and it would gain access to the local variables of
  25.    the enclosing frame.  
  26.  
  27.    In general, this is re-entrant safe.  That is to say, the client keeps
  28.    track of each stack as it is locked by wait, and matches it up with
  29.    the each bless request, so that no matter how many times wait
  30.    may be nested, it will be correctly matched up with each bless.
  31.  
  32. Practical:
  33.    This is best demonstrated with an example:
  34.  
  35.     alias uh 
  36.     {
  37.         ^local blahblah
  38.         wait for {
  39.             ^userhost $* -cmd {
  40.                 bless
  41.                 push blahblah $3@$4
  42.             }
  43.         }
  44.         return $blahblah
  45.     }
  46.  
  47. See Also:
  48.    wait(1); on(1); timer(1); queue(1)
  49.  
  50.