Skip to content
Tcl Source Code History Of Ticket 0e48e053283e6fb8
Login

History Of Ticket 0e48e053283e6fb8

Artifacts Associated With Ticket 0e48e053283e6fb8

  1. Ticket change [81c6496a98] (rid 162086) by anonymous on 2018-03-26 16:21:37:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      The manual page for the [apply] command describes the semantics of the command with a pure Tcl procedure. However, that implementation would never clean up created procedures, leading to memory leaks where the [apply] command is parameterised in, say, a loop. It would be good to mention that, unlike the pure Tcl description, [apply] commands are cleaned up with the reference count system just as with any other Tcl values.
      
      Alternatively the semantics code could be altered to destroy the newly created command before [return].
      
    5. foundin initialized to: "8.6"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "0dfe2e6aa820af3598e203fec901fc46f1ba3c95"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "anonymous"
    14. subsystem initialized to: "16. Commands A-H"
    15. title initialized to: "Clarify that [apply] functions are cleaned up"
    16. type initialized to: "Bug"
  2. Ticket change [69fa1ebcec] (rid 162096) by sebres on 2018-03-26 20:02:35:

    1. icomment:
      1. If you meant the interim proc "$name" created inside example in the manual page - it will be already removed. 
      Possibly you overlooked one thing, the example does additionally - the clean-up with "rename [lindex [info level 0] 0] {}", which deletes itself implicitly before it returns from each "apply-proc".
      
      2. In part where the manual page describes the semantics "with a pure Tcl procedure" it meant just really semantic only - so it is similar as it acts like this proc.
      
      So if you meant any other case, like create another proc inside...
      The case where something evaluable (inclusive the command "apply") creates a "sub" proc inside of its body, is equivalent to any other script-level bodies where proc will be created (tcl does not have scope-bound proc's at all, so never implicit removed).
      
      So it means - the proc's created from everywhere are always persistent (until removed using `rename $name {}`.
      And body of apply-lambda does not different compared to any other evaluated tcl-body.
      
      This is not a leak (despite the proc inside will be normally always overwritten, if same name used).
      
      So in following example both are almost equivalent:
      <pre><code>
      proc test {a b} {
        proc log_params {args} {puts "execute [info level [info level]]"}
        log_params a $a b $b
      }
      test A B
      
      set lambda {{a b} {
        proc log_params {args} {puts "execute [info level [info level]]"}
        log_params a $a b $b
      }}
      apply $lambda A B
      </code></pre>
      In both cases the proc is created inside body (note it's compiled only once because of tcl-jit-compiler).
      
      Thus could you explain firstly which of both cases did you meant?
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Invalid"
    5. status changed to: "Pending"
  3. Ticket change [127409bdcd] (rid 258121) by serhiy.storchaka on 2026-10-15 11:29:05:

    1. icomment: "Closing: answered above."
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
    4. status changed to: "Closed"
  4. Ticket change [0fa807782e] (rid 259925) by serhiy.storchaka on 2026-10-22 17:19:26:

    1. closedate changed to: "2461328.9785312153"
    2. closer changed to: "serhiy.storchaka"
    3. login: "serhiy.storchaka"