TCL Namespaces

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCL Namespaces

  • Creator
    Topic
  • #48444
    Mark McGrath
    Participant

      We have placed ODBC connection error handling, SQL select, and SQL creation procs in two separte namespaces in a TCL proceedure.  Most of the code Quovadx personel created and setup.

           We created other tcl procs to do database SQL calls as needed.  We have been having trouble accessing the namespace procedures.  We noticed that the tcl procs in a namespace do not show up in the tclIndex file.  Is there a way to get namespaces to show up in the tclIndex?  

          Is anyone else using namespaces in their tcl procs?  Can namespace procedures be accessed from other tcl procs in different tcl files?

      Mark McGrath

      HSHS

    Viewing 2 reply threads
    • Author
      Replies
      • #58650
        Charlie Bursell
        Participant

          The whole purpose of creating a namespace is to provide a private area that can be accessed only if you know the name of the area.  To show up procs from a namespace in tclIndex would be counter to this.

          Also, in most cases. namespace procs are not meant to be callable procs, they are meant to be like subroutines.

          Anyone can access a procedure or a variable in a namespace as long as they know the name of the namespace and that namespace has been loaded into the Tcl interpreter that you are in.  You can do this by simply having the namespace in the same file as the proc you are using or by placing it in a Tcl package and loading it as needed with the package require command.

          Namespaces are a valuable programming tool but, like everything else in the programming world, only if used properly.

          I would suggest Chapter 14 of “Practical Programming in Tcl and TK,  4th Edition” By Brent Welch and others

        • #58651
          Richard Hart
          Participant

            Mark.

            As Charlie has indicated, we use namespaces to load variables that are private to the thread and code they are in.  We have our namespace wrapped within a ‘set’ and ‘get’ function and generally use them to:

            store constants, set by a configuration file;  or

            store session variables; or

            make a variable ‘global’ to all functions within the code.

          • #58652
            Mark McGrath
            Participant

              Thanks for the responses.  I will give the package option a try.  That would eliminate alot of duplicate code and still allow us to keep the namespaces.  

              Mark McGrath

              HSHS

          Viewing 2 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.