Skip to content
Tcl Source Code History Of Ticket 219376
Login

History Of Ticket 219376

Artifacts Associated With Ticket 219376

  1. Ticket change [9647faa9f3] (rid 106298) by nobody on 2000-10-26 05:11:50:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 6006 RFE
      Version: 8.4a1
      SubmitDate: '2000-07-12'
      LastModified: '2000-10-25'
      Severity: LOW
      Status: UnAssn
      Submitter: techsupp
      OS: All
      FixedDate: '2000-10-25'
      ClosedDate: '2000-10-25'
      
      
      Name:
      Philip Moore
      
      Comments:
      Then here's some TCL code to try to explain (if you don't already
          understand what I'm saying):
      
          It would be extremely handy if I could do this:
      
          if {[foreach a "a b c d" { do whatever stuff on $a and $arg here }] ==
          "c"} { }
      
          That would save me from having to do all this:
      
          if {"[mycommand $arg]" == "c"} { }
      
          proc mycommand {arg} {
            foreach a "a b c d" { do whatever stuff on $a and $arg here } 
            return $result 
          }
      
          Also, if for, foreach, and while returned the results of the last thing
          inside them you could have a proc like this:
      
          proc someproc {arg} {
             for {set x 0} {$x<$arg} {incr x} {
               lappend out "x is $x"
             }
          }
      
          Instead of having this:
      
          proc someproc {arg} {
             for {set x 0} {$x<$arg} {incr x} {
               lappend out "x is $x"
             }
             set out
          }
      
          I know my examples were kinda poor.. But they should have gotten my
          point across.. 
          And before somebody says this is a bad idea.. I have to say this..
          proc's themselves already return the results of the last command, so why
          can't for, foreach, and while?
      
          -Philip Moore 
          [email protected]
      
          p.s.
          Please CC any replies to [email protected] as I don't have access to
          the newsgroup.
      
      DesiredBehavior:
      The commands for, foreach, and while don't pass the results of the last command inside them.. It'd be nice, I think, if they did.. (Currently, they always return "")
      
      
      
      
      
    4. foundin initialized to: "obsolete: 8.4a1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to:
      New Feature Request: Pass the results of the last command in
      
    11. type initialized to: "RFE"
  2. Ticket change [28a5490a53] (rid 88737) by dkf on 2000-11-22 23:45:58:

    1. foundin changed to: "obsolete: 8.4a3"
    2. icomment:
      Speaking as an old functional programmer, it would be very nice if the [if] command returned the result of the last command of whatever body it ends up executing.
      I'm less sure about returning values from [for], [foreach] and [while] since the cost of constructing the natural results of those commands (which is the list of the results of the last command of their bodies from each execution) is likely to be very expensive to compute in terms of memory.  Returning the value from the final execution of a loop body doesn't seem very intuitive to me...
      Not that any of this should be taken as being against defining a separate command with the semantics described, since that would be an "opt-in" as opposed to "forced-upon"; i.e. people would use it where it makes sense according to the algorithm being implemented, and not otherwise.  (For example, a collecting [foreach] command is more commonly known as [map] in the functional-programming community.)
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. username: "dkf"
  3. Ticket change [3178dc9dbd] (rid 93432) by andreas_kupries on 2000-11-23 15:30:15:

    1. icomment:
      With respect to "map", this is provided by "listx" (And some more :).
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  4. Ticket change [6f98133ebb] (rid 100341) by andreas_kupries on 2000-11-23 18:38:31:

    1. subsystem changed to: "81. Bundled Packages"
  5. Ticket change [513a4cdf0a] (rid 126103) by dkf on 2001-02-07 23:06:26:

    1. subsystem changed to: "16. Commands A-H"
    2. title changed to:
      Pass result of last command in for, foreach, and while
      
  6. Ticket change [5350d590e3] (rid 93735) by dkf on 2001-02-15 23:28:17:

    1. assignee changed to: "dkf"
  7. Ticket change [9ea36c9ecc] (rid 96514) by dkf on 2001-02-28 17:52:38:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Hmm. [if] does return the result of the last command it
      executes in its bodies.  I wonder how I missed that...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  8. Ticket change [6bf80139ce] (rid 128417) by dgp on 2001-04-04 04:57:25:

    1. subsystem changed to: "16. Commands A-H"
  9. Ticket change [018ac3fe66] (rid 119500) by dkf on 2001-12-18 21:58:01:

    1. priority changed to: "2"
  10. Ticket change [86a09de5f9] (rid 261527) by serhiy.storchaka on 2026-11-13 11:18:44:

    1. closedate changed to: "2461357.9713335303"
    2. closer changed to: "serhiy.storchaka"
    3. icomment:
      The loop commands still return an empty result, but the collecting loop dkf suggested was added in Tcl 8.6 as lmap and dict map (TIP 405).
      
    4. login: "serhiy.storchaka"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Out of Date"
    7. status changed to: "Closed"