Skip to content
Tcl Source Code History Of Ticket 793779ffffffffffffffffffffffffffffffffff
Login

History Of Ticket 793779ffffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 793779ffffffffffffffffffffffffffffffffff

  1. Ticket change [9b07e2b6b2] (rid 111056) by elfring on 2003-08-23 14:58:09:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Multiple inclusion of source files can be avoided in compiled 
      programming languages like C++ by preprocessor 
      statements.
      ...
      #if 
      !defined(_my_text_included)
      #include 
      "my_text.h"
      #endif
      ...
      
      The TCL function 
      "source" includes files, too. But there are no preprocessor 
      directives in a scripting language like TCL. Their statements get 
      executed every time.
      The language PHP provides the 
      function "http://de.php.net/manual/en/function.include-
      once.php".
      
      I suggest to add the option "-once" to avoid 
      multiple inclusions of TCL code.
      
      ...
      if 
      {_my_text_included == 0} \
       {
        source "my_text.h"
       
      }
      ...
      # Write just one line to achieve the same as before 
      with more safety
      source -once "my_text.h"
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "elfring"
    9. subsystem initialized to: "18. Commands M-Z"
    10. title initialized to: "Include source files only once"
    11. type initialized to: "RFE"
  2. Ticket change [04f89892b9] (rid 88964) by dkf on 2003-08-24 22:32:48:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2003-08-24T15:32:48"
    3. closer changed to: "dkf"
    4. icomment:
      Logged In: YES 
      user_id=79902
      
      I'd suggest using packages instead, and [package require]
      works a bit like [source -once] would except it uses a
      slightly more abstract notion (package name) and works with
      things other than single Tcl script files.
      
      dgp: Please reopen if you disagree.
      
      
    5. login: "dkf"
    6. mimetype: "text/plain"
    7. resolution changed to: "Rejected"
    8. status changed to: "Closed"
    9. username: "dkf"
  3. Ticket change [1917a1947c] (rid 122763) by elfring on 2003-08-25 02:41:46:

    1. icomment:
      Logged In: YES 
      user_id=572001
      
      I do not want to create a package for every file that needs to be inluded 
      once.
      I think that is to much work.
      
      
    2. login: "elfring"
    3. mimetype: "text/plain"
    4. resolution changed to: "Later"
    5. status changed to: "Open"
    6. username: "elfring"
  4. Ticket change [de7d7f5bf1] (rid 114862) by dgp on 2003-08-25 06:43:53:

    1. closedate changed to: "2003-08-24T23:43:53"
    2. closer changed to: "dgp"
    3. icomment:
      Logged In: YES 
      user_id=80530
      
      Perhaps auto-loading is a
      more attractive alternative
      for you?
      
      http://wiki.tcl.tk/tclindex
      
      Either auto-loading or packages
      is the right answer.  Adding this
      kind of magic to [source] is
      not a good idea.
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. resolution changed to: "Rejected"
    7. status changed to: "Closed"
    8. username: "dgp"
  5. Ticket change [e14fa15242] (rid 87425) by elfring on 2003-08-25 18:59:20:

    1. icomment:
      Logged In: YES 
      user_id=572001
      
      Sorry - I've got an opposite opnion.
      
      "...
      Auto 
      Loading
      
      If you're building a library of tcl scripts, you should 
      consider using utilizing one of Tcl's auto-loading 
      mechanisms.
      ..."
      
      I do not want to build a library.
      I do 
      not think that a function [source -once $file] is "magic". It may be seen a 
      little bit as a convenience feature. But it can provide more speed and 
      safety.
      
      
    2. login: "elfring"
    3. mimetype: "text/plain"
    4. status changed to: "Open"
    5. username: "elfring"
  6. Ticket change [e4c7dc49bf] (rid 88018) by dgp on 2003-08-25 21:24:03:

    1. closedate changed to: "2003-08-25T14:24:03"
    2. closer changed to: "dgp"
    3. icomment:
      Logged In: YES 
      user_id=80530
      
      
      OK, let me try putting is a different
      way then.
      
      [source] is, and should remain, a
      fairly primitive operation.  The kind
      of one-time loading constraint is
      better implemented as a higher level
      routine that calls on [source] just to
      do the sourcing work, and maintains
      its own store of already sourced 
      file names to avoid duplication.
      This can be achieved in a [proc]
      of less than 20 lines, so I don't see
      any need for changes to the core
      interface.
      
      When writing that [proc], consider
      applying [file normalize] to the file
      names before storing.
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "dgp"
  7. Ticket change [e4064917de] (rid 87892) by elfring on 2003-08-25 23:45:05:

    1. icomment:
      Logged In: YES 
      user_id=572001
      
      I understand your intention now.
      
      How do you think about to 
      create a new command [include $file] that implements the "one-time 
      loading constraint"?
      Can these "20 lines" be added to the standard 
      TCL function library so that all the developers do not need to write 
      several versions for it on their own?
      
      
    2. login: "elfring"
    3. mimetype: "text/plain"
    4. resolution changed to: "Later"
    5. status changed to: "Open"
    6. username: "elfring"
  8. Ticket change [be1d2259b6] (rid 102021) by dkf on 2003-08-26 02:20:57:

    1. closedate changed to: "2003-08-25T19:20:57"
    2. closer changed to: "dkf"
    3. icomment:
      Logged In: YES 
      user_id=79902
      
      Given that neither dgp nor myself feel very happy about
      adding this feature, please could you tell us a bit more
      about a specific situation where this would be useful but
      existing solutions (based upon the package mechanism and
      autoloading) do not satisfy.  I've had a think about this,
      and all I can really think of is some kind of (possibly
      per-application) library, which is already covered by the
      features already listed.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. status changed to: "Pending"
    7. username: "dkf"
  9. Ticket change [092c3c079c] (rid 89674) by elfring on 2003-08-26 03:48:48:

    1. icomment:
      Logged In: YES 
      user_id=572001
      
      1. The autoloading mechanism depends on the variable "auto_path". I 
      see it as a system setting over which I have not the control all the 
      time.
      - http://mini.net/tcl/1628
      - 
      http://tcl.tk/man/tcl8.4/TclCmd/tclvars.htm
      
      2. The 
      package mechanism needs even more configuration.
      
      3. A new 
      function [include $file] can give developers that are used to 
      programming languages like PHP an easier way to source TCL code.
      
      
    2. login: "elfring"
    3. mimetype: "text/plain"
    4. status changed to: "Open"
    5. username: "elfring"
  10. Ticket change [966eac4367] (rid 106326) by elfring on 2003-08-26 03:58:04:

    1. icomment:
      Logged In: YES 
      user_id=572001
      
      4. It seems that this request runs into a discussion about the topic to do 
      things the TCL way.
      
      5. How do you think about a little "hack" that 
      a developer creates a package that contains the requested function 
      "include"?
         It will be a normal extension in this case.
      
      
    2. login: "elfring"
    3. mimetype: "text/plain"
    4. username: "elfring"
  11. Ticket change [8e9b2d6e7b] (rid 120140) by dkf on 2003-08-26 04:16:18:

    1. closedate changed to: "2003-08-25T21:16:18"
    2. closer changed to: "dkf"
    3. icomment:
      Logged In: YES 
      user_id=79902
      
      1.If your apps can't control their variables, they're in
      trouble. Seriously. And libraries should not be altering
      ::auto_path under normal circumstances. (I'm not convinced
      that you've got non-normal circumstances here.)
      2.If you're building a library, use the facilities provided.
      They're tested and maintained.
      3.I thought the PHP mechanism was for script libraries. But
      then where I work PHP is something of a byword for security
      holes.
      4.Too right, and you have two people saying this isn't the
      Tcl Way
      5.You can do *anything* you want in your own code. It's yours.
      
      Still waiting for that killer use-case.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. status changed to: "Pending"
    7. username: "dkf"
  12. Ticket change [200ec98513] (rid 91249) by elfring on 2003-08-26 05:36:12:

    1. icomment:
      Logged In: YES 
      user_id=572001
      
      1. I want to leave the system variable "auto_path" untouched.
         A 
      release note for the package "http://oratcl.sourceforge.net/" talks 
      about "auto_path idiosyncracies".
      
      2. I know. The descriptions 
      "http://www.tcl.tk/doc/tea/" look like too much work for some 
      situations.
      
      3. PHP developers know the functions 
      "require_once" and "include_once". The requested comfort is 
      provided by PHP.
         It can be added to TCL with the same name. You 
      have got the opinion that this should not belong to the core library so 
      far.
      
      4. I am trying to introduce a topic that I do not see 
      "tclish".
      
      5. The command [package require $extension] is the 
      only function that avoids multiple inclusions at the moment.
         If a 
      new package cannot be build because of administration 
      circumstances, you must look for other safe ways to include a small file 
      collection.
         Am I the only one that is interested in this little 
      enhancement?
      
      
    2. login: "elfring"
    3. mimetype: "text/plain"
    4. status changed to: "Open"
    5. username: "elfring"
  13. Ticket change [1ef9f4d5f4] (rid 91068) by mistachkin on 2003-08-26 05:55:00:

    1. icomment:
      Logged In: YES 
      user_id=113501
      
      This type of functionality does not need to be included in the 
      core to be useful.
      
      proc sourceOnce { file } {
        upvar "1" sources sources
      
        if {![info exists sources([file normalize $file])]} then {
          # don't catch errors, since that may indicate 
          # we failed to load it...?
          uplevel "1" [list source $file]
          # mark it as loaded since it was source'd with no error...
          set sources([file normalize $file]) "1"
        }
      }
      
      
      
    2. login: "mistachkin"
    3. mimetype: "text/plain"
    4. username: "mistachkin"
  14. Ticket change [4c64db368d] (rid 126888) by dgp on 2003-08-26 09:41:59:

    1. resolution changed to: "Rejected"
    2. status changed to: "Closed"
  15. Ticket change [be5c8286b4] (rid 102061) by dgp on 2003-08-26 09:42:00:

    1. closedate changed to: "2003-08-26T02:42:00"
    2. closer changed to: "dgp"
    3. icomment:
      Logged In: YES 
      user_id=80530
      
      
      I'm referring further discussion 
      on development of such a
      utility command to the wiki.
      
      http://wiki.tcl.tk/source
      
      There's no longer a feature
      request for Tcl here.  Best next
      step is to create the command
      (see wiki) and use it for yourself.
      Offer it to others.  If it's useful
      and popular, it will find a home
      in a widely used package (maybe
      distributed in tcllib or ActiveTcl?)
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. username: "dgp"