Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 38941f20d51d7434510b508754274f8dacef960a
Ticket: 3048771fffffffffffffffffffffffffffffffff
tailcall constraints chafe with control command procs
User & Date: dgp on 2010-08-19 16:20:31
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    
    A celebrated feature of Tcl is the ability to replace
    built-in commands with functionally equivalent procs.
    The constraints on [tailcall] diminish that ability.
    
    Utility command from TIP 90:
    
    % namespace eval control {
         proc ascaller script {
             if {[info level] < 2} {
                 return -code error \
                         "[lindex [info level 0] 0] called outside a proc"
             }
             variable result
             variable options
             set code [uplevel 2 \
                     [list ::catch $script   [namespace which -variable result] \
                                             [namespace which -variable options]]]
             if {$code == 0} {
                 return $result
             }
             dict incr options -level 2
             return -options $options $result
         }
     }
    % proc myIf {cond body} {
        set bool [control::ascaller [list ::expr $cond]]
        if {!$bool} return
        return [control::ascaller $body]
    }
    % proc good {} {if 1 {tailcall concat}}
    % good
    % proc bad {} {myIf 1 {tailcall concat}}
    % bad
    tailcall can only be called from a proc or lambda
    
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "dgp"
  10. subsystem changed to: "45. Parsing and Eval"
  11. title changed to:
    tailcall constraints chafe with control command procs
    
  12. type changed to: "Bug"