vwait should allow local scope
Closed / Fixed218414ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:57:17
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
welch Closed ticket [218414ffff].
[History diff]2000-10-26 08:21:18
Log in (anonymous is fine) to add a comment.