Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2ca0eeaa15b8db16d77b5ea787db267a953692e6
Ticket: 218414ffffffffffffffffffffffffffffffffff
vwait should allow local scope
User & Date: nobody on 2000-10-26 00:57:17
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 5492 RFE
    Version: 8.2.1
    SubmitDate: '2000-05-15'
    LastModified: '2000-05-15'
    Severity: LOW
    Status: Closed
    Submitter: techsupp
    ChangedBy: hobbs
    OS: Solaris
    OSVersion: 2.6
    Machine: sun4u
    FixedDate: '2000-10-25'
    ClosedDate: '2000-05-15'
    
    
    Name:
    Benjamin Vitale
    
    DesiredBehavior:
    In Tcl_VwaitObcCmd, you call Tcl_TraceVar with the TCL_GLOBAL_ONLY flag.  I just ran up against the 
    same problem as in bug id #3329 (I tried to append my experience to that bug, but the bugdb sent me here.)
    It took me 5 minutes to figure out what the problem was.
    
    Anyway, I guess this was a bit counter-intuitive.  I can see Jeff's point about not wanting to trace a local var, although I write code
    all the time to do timeouts in non-event driven apps that would exploit even local vars, if I could.  In general, I think we should
    facilitate tools that limit global vars.  At least, it would be nice to allow vwait on namespace vars, if not locals.  Instead, I have to do
    vwait name::space::var
    
    For example,
    
    proc timed_connect {host port timeout} {
      global sem ;# would be nice if I could avoid this.  at least with a namespace, or just use as a local
    
      set s [socket -async $host $port]
      after $timeout {set sem timeout}
      fileevent $s writable {set sem ready}
      vwait sem
      etc.
    }
    
    Thanks for updating vwait.n man page.
    
    BTW, in the 8.2.1 man page namespace.n, you write "See the section SCOPED VALUES..." but I can not find this section.
    
    
    
    It's perfectly correct to use namespace'd vars instead of global ones:
    
    (tkcon) 50 % namespace eval ::foo { variable bar 1 }
    (tkcon) 51 % after 10000 set ::foo::bar 20
    after#3
    (tkcon) 52 % vwait ::foo::bar ; puts hello
    hello
    
    but the var must just be globally scoped ( it would be dangerous
    to say just 'bar', always use the '::foo::bar' construct instead,
    or combine with [namespace current]). 
    -- 05/15/2000 hobbs
    But the user points our that simple, defined local vwaits would be
    useful.  The problem is that you couldn't actually effect the above
    after, or set the sem that way - after always occurs at the global
    scope as well.  Since you can't reenter into that same ephemeral
    proc scope, you can't use vwait in this way. 
    -- 05/15/2000 hobbs
    
  4. foundin changed to: "obsolete: 8.2.1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "07. Variables"
  10. title changed to: "vwait should allow local scope"
  11. type changed to: "Bug"