From 8f1c3339a680dd2ca8319a0643711151f0c85698 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sat, 23 Apr 2011 16:40:38 +1000 Subject: Document changes to [local proc] and [upcall] Signed-off-by: Steve Bennett --- Tcl_shipped.html | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'Tcl_shipped.html') diff --git a/Tcl_shipped.html b/Tcl_shipped.html index bb3bd90..fbe5fbd 100644 --- a/Tcl_shipped.html +++ b/Tcl_shipped.html @@ -715,6 +715,11 @@ Support jimsh --version Additional variables in tcl_platform()

+
  • +

    +local procs now push existing commands and upcall can call them +

    +
  • @@ -961,8 +966,8 @@ no longer work.

    COMMENTS

    -

    If the first non-blank character in a command is #, then everything -from the # up through the next newline character is treated as +

    If the first non-blank character in a command is #, then everything +from the # up through the next newline character is treated as a comment and ignored. When comments are embedded inside nested commands (e.g. fields enclosed in braces) they must have properly-matched braces (this is necessary because when Tcl parses the top-level command @@ -1465,8 +1470,8 @@ If a field doesn’t begin with a brace then backslash,

  • -If the first non-blank character of a command is a #, everything - from the # up through the next newline is treated as a comment +If the first non-blank character of a command is a #, everything + from the # up through the next newline is treated as a comment and ignored.

  • @@ -1642,7 +1647,7 @@ of precedence:

    -< > \<= >= +< > <= >=

    @@ -1828,7 +1833,7 @@ its second argument to the expression evaluator to see whether or not to continue processing. Unfortunately, in this case the value of i in the second argument will be substituted once and for all when the for command is parsed. If i was 0 before the for -command was invoked then for’s second argument will be 0\<=10 +command was invoked then for’s second argument will be 0<=10 which will always evaluate to 1, even though i eventually becomes greater than 10. In the above case the loop will never terminate. Instead, the expression should be placed in braces:

    @@ -1862,7 +1867,7 @@ the string

    a b\ c {d e {f g h}}
    -

    is a list with three elements: a, b c, and d e {f g h}.

    +

    is a list with three elements: a, b c, and d e {f g h}.

    Whenever an element is extracted from a list, the same rules about braces and quotes and backslashes are applied as for commands. Thus in the example above when the third element is extracted from the list, @@ -2716,11 +2721,12 @@ cellspacing="0" cellpadding="4">

    try

    unknown

    unset

    +

    upcall

    update

    uplevel

    -

    upvar

    +

    upvar

    vwait

    while

    @@ -2728,7 +2734,6 @@ cellspacing="0" cellpadding="4">

    -

    @@ -4255,6 +4260,10 @@ value to be a procedure name, which is marked as having local scope. This means that when the current procedure exits, the specified procedure is deleted. This can be useful with lambda or simply local procedures.

    +

    In addition, if a command already exists with the same name, +the existing command will be kept rather than deleted, and may be called +via upcall. The previous command will be restored when the current +command is deleted. See upcall for more details.

    In this example, a local procedure is created. Note that the procedure continues to have global scope while it is active.

    @@ -5933,6 +5942,13 @@ is specified. The -- argument may be specified to stop option processin in case the variable name may be -nocomplain.

    +

    upcall

    +

    upcall command ?args …?

    +

    May be used from within a proc defined as local proc in order to call +the previous, hidden version of the same command.

    +

    If there is no previous definition of the command, an error is returned.

    +
    +

    uplevel

    uplevel ?level? command ?command …?

    All of the command arguments are concatenated as if they had @@ -5943,14 +5959,14 @@ it gives a distance (up the procedure calling stack) to move before executing the command. If level consists of # followed by a number then the number gives an absolute level number. If level is omitted then it defaults to 1. Level cannot be -defaulted if the first command argument starts with a digit or \#.

    +defaulted if the first command argument starts with a digit or #.

    For example, suppose that procedure a was invoked from top-level, and that it called b, and that b called c. Suppose that c invokes the uplevel command. If level -is 1 or \#2 or omitted, then the command will be executed -in the variable context of b. If level is 2 or \#1 +is 1 or #2 or omitted, then the command will be executed +in the variable context of b. If level is 2 or #1 then the command will be executed in the variable context of a.

    -

    If level is 3 or \#0 then the command will be executed +

    If level is 3 or #0 then the command will be executed at top-level (only global variables will be visible). The uplevel command causes the invoking procedure to disappear from the procedure calling stack while the command is being executed. @@ -5983,10 +5999,10 @@ procedure to refer to variables in an enclosing procedure call or to global variables.

    Level may have any of the forms permitted for the uplevel command, and may be omitted if the first letter of the first otherVar -isn’t \# or a digit (it defaults to 1).

    +isn’t # or a digit (it defaults to 1).

    For each otherVar argument, upvar makes the variable by that name in the procedure frame given by level (or at -global level, if level is \#0) accessible +global level, if level is #0) accessible in the current procedure by the name given in the corresponding myVar argument.

    The variable named by otherVar need not exist at the time of the @@ -6961,7 +6977,7 @@ official policies, either expressed or implied, of the Jim Tcl Project.


    -- cgit v1.1