home *** CD-ROM | disk | FTP | other *** search
-
-
-
- uuuuppppvvvvaaaarrrr((((nnnn)))) TTTTccccllll (((( )))) uuuuppppvvvvaaaarrrr((((nnnn))))
-
-
-
- _________________________________________________________________
-
- NNNNAAAAMMMMEEEE
- upvar - Create link to variable in a different stack frame
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- uuuuppppvvvvaaaarrrr ?_l_e_v_e_l? _o_t_h_e_r_V_a_r _m_y_V_a_r ?_o_t_h_e_r_V_a_r _m_y_V_a_r ...?
- _________________________________________________________________
-
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- This command arranges for one or more local variables in the
- current procedure to refer to variables in an enclosing
- procedure call or to global variables. _L_e_v_e_l may have any
- of the forms permitted for the uuuupppplllleeeevvvveeeellll command, and may be
- omitted if the first letter of the first _o_t_h_e_r_V_a_r isn't #### or
- a digit (it defaults to 1111). For each _o_t_h_e_r_V_a_r argument,
- uuuuppppvvvvaaaarrrr makes the variable by that name in the procedure frame
- given by _l_e_v_e_l (or at global level, if _l_e_v_e_l is ####0000)
- accessible in the current procedure by the name given in the
- corresponding _m_y_V_a_r argument. The variable named by
- _o_t_h_e_r_V_a_r need not exist at the time of the call; it will be
- created the first time _m_y_V_a_r is referenced, just like an
- ordinary variable. UUUUppppvvvvaaaarrrr may only be invoked from within
- procedures. _M_y_V_a_r may not refer to an element of an array, |
- but _o_t_h_e_r_V_a_r may refer to an array element. UUUUppppvvvvaaaarrrr returns
- an empty string.
-
- The uuuuppppvvvvaaaarrrr command simplifies the implementation of call-by-
- name procedure calling and also makes it easier to build new
- control constructs as Tcl procedures. For example, consider
- the following procedure:
-
- pppprrrroooocccc aaaadddddddd2222 nnnnaaaammmmeeee {{{{
- uuuuppppvvvvaaaarrrr $$$$nnnnaaaammmmeeee xxxx
- sssseeeetttt xxxx [[[[eeeexxxxpppprrrr $$$$xxxx++++2222]]]]
- }}}}
- AAAAdddddddd2222 is invoked with an argument giving the name of a
- variable, and it adds two to the value of that variable.
- Although aaaadddddddd2222 could have been implemented using uuuupppplllleeeevvvveeeellll
- instead of uuuuppppvvvvaaaarrrr, uuuuppppvvvvaaaarrrr makes it simpler for aaaadddddddd2222 to access
- the variable in the caller's procedure frame.
-
- If an upvar variable is unset (e.g. xxxx in aaaadddddddd2222 above), the |
- uuuunnnnsssseeeetttt operation affects the variable it is linked to, not |
- the upvar variable. There is no way to unset an upvar |
- variable except by exiting the procedure in which it is |
- defined. However, it is possible to retarget an upvar |
- variable by executing another uuuuppppvvvvaaaarrrr command.
-
-
-
-
- Page 1 (printed 7/17/95)
-
-
-
-
-
-
- uuuuppppvvvvaaaarrrr((((nnnn)))) TTTTccccllll (((( )))) uuuuppppvvvvaaaarrrr((((nnnn))))
-
-
-
- KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
- context, frame, global, level, procedure, variable
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 2 (printed 7/17/95)
-
-
-
-