Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c577d8373f8b44e2415dc9bd4a24a05e1d7287c5
Ticket: 9ca25bce1341913e910f612f13a64ac9cfea2598
There is no notion of local procedure inside a procedure
User & Date: dkf on 2015-05-16 06:11:07
Changes

  1. assignee changed to: "dkf"
  2. closedate changed to: "2457158.75773043"
  3. closer changed to: "dkf"
  4. icomment:
    <blockquote>They are not deleted when the function returns.</blockquote>
    This is correct, and there's <i>a lot of existing code</i> that relies on exactly this behaviour (so one can have procedures that create other permanent procedures) so it definitely won't be changing in the way that you ask for.<p>If you want procedure-like things that will be automatically deleted at the end, use lambda terms. That works well and they are almost as simple to use as procedures (just <tt>apply $term</tt> instead of the procedure name):
    <pre>
    proc foo {r s t} {
        set bar {{x y} {
            set z [expr {$x**2 + $y**3}]
            return [expr {17 * $z + 42}]
        }}
        set z "example $t"
        set abc [apply $bar $r $s];    #### <<<<<<<<<<<<<
        return [list $z $abc $z]
    }
    </pre>
    
  5. login: "dkf"
  6. mimetype: "text/html"
  7. resolution changed to: "Wont Fix"
  8. status changed to: "Closed"
  9. subsystem changed to: "22. [proc] and [uplevel]"
  10. username: "dkf"