Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2fa5f7ec77d84141757544a5d6f556c090382744
Ticket: 9ca25bce1341913e910f612f13a64ac9cfea2598
There is no notion of local procedure inside a procedure
User & Date: anonymous on 2015-04-18 02:57:58
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    Hi,
    when objects are created inside a procedure using TclOO they are global to all the current namespace. They are not deleted when the function returns.
    
    The problem is that these objects are commands. And all commands, including the ones that are created inside another procedures, are global to all the current namespace. The situation is totally different with variables. When a variable is defined inside a function, this variable is local to this function. When the function returns, this variable does not exists. But inside a procedure, this variable can be global to all the namespace using the global command.
    
    I think that this behaviour should be equal with procs. All the procs defined inside another proc should be local, unless they are indicated as globals with the global command. Otherwise each time a user define objects using TclOO inside a function they will not be deleted automatically when the function returns. 
    
    Another possible approach is to create all the objects inside a specific namespace, and delete this namespace before the function returns.
    
    But the automatic deletion of local procedures defined inside another procedure, I think that it's a better solution because the user doesn't need to worry about to create a special namespace and delete this namespace before the functions returns.
    
    Another choice is to have a control of all the created objects using a static variable in the class. And before the function returns call a specific static method of the class to remove all the created objects. Again, the drawback with this approach is that the user needs to worry about to make a clean-up before the function returns calling this method.
    
  5. foundin changed to: "8.6"
  6. is_private changed to: "0"
  7. login: "anonymous"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "1c4b6cdb98c9dfc4d1e74018f3f4efa00ad217e2"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "anonymous"
  14. subsystem changed to: "07. Variables"
  15. title changed to:
    There is no notion of local procedure inside a procedure
    
  16. type changed to: "Bug"