Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-09-30
01:38 • Ticket [219387ffff] info locals seems not to work properly status still Clos... artifact: d1818c63d0 user: dgp
01:38 • Closed ticket [219387ffff]. artifact: 72e1120c4a user: dgp
2008-09-27
21:21 • Ticket [219387ffff]: 4 changes artifact: 3d13028b70 user: phoinix77
2008-08-30
02:48 • Ticket [219387ffff]: 4 changes artifact: 032dd6a799 user: dgp
2008-08-29
22:51 • Ticket [219387ffff]: 4 changes artifact: e9d6c6dc03 user: phoinix77
21:50 • Ticket [219387ffff]: 1 change artifact: f66e79c78e user: dgp
21:20 • Ticket [219387ffff]: 5 changes artifact: 805605a703 user: dkf
21:08 • Open ticket [219387ffff]. artifact: c3ed2de85d user: dgp
2001-04-04
12:44 • Ticket [219387ffff]: 2 changes artifact: 5d85b234b5 user: dgp
12:44 • Ticket [219387ffff]: 1 change artifact: 102d75e3bc user: dgp
2000-12-01
20:56 • Ticket [219387ffff]: 6 changes artifact: 877bf953d9 user: dkf
19:19 • Ticket [219387ffff]: 4 changes artifact: 2044ca585d user: mzi
2000-11-21
22:56 • Closed ticket [219387ffff]. artifact: 9fd70bdd6e user: dkf
2000-11-15
21:58 • Ticket [219387ffff]: 5 changes artifact: 3eceb887fc user: dkf
2000-10-26
05:12 • New ticket [219387ffff]. artifact: 2e5d2942de user: nobody

info locals seems not to work properly

Closed / Fixed219387ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 18 years ago
Descriptionplain2000-10-26 05:12:08
OriginalBugID: 6131 Bug
Version: 8.3.2
SubmitDate: '2000-08-14'
LastModified: '2000-10-25'
Severity: MED
Status: UnAssn
Submitter: techsupp
OS: Linux-SuSE
OSVersion: SuSE 6.4
Machine: AMD K6
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'


Name:
Christian Eva

ReproducibleScript:
proc xloc {args} {
    global Defaults LikeDictionaries env L1
    global Dictionaries

    foreach m $args {
        set $m $m
    }

    puts "locals=[info locals]"

    set L1 [info locals]
    puts "L1=$L1"

    unset args

    foreach a [info locals {[a-zA-Z]?*}] {
        puts "a=$a"
        eval set v \$$a
        set Dictionaries($a) $v
    }
}

set L1 empty

xloc a aA b Ba ccc 

puts "L1=$L1"

parray Dictionaries
# end

bash-2.03$ tclsh8.0 localtest
locals=args m L1 a ccc b aA Ba
L1=args m L1 a ccc b aA Ba
a=L1
a=ccc
a=aA
a=Ba
L1=args m L1 a ccc b aA Ba
Dictionaries(Ba)  = Ba
Dictionaries(L1)  = args m L1 a ccc b aA Ba
Dictionaries(aA)  = aA
Dictionaries(ccc) = ccc
bash-2.03$ 

bash-2.03$ tclsh8.3 localtest
locals=args m L1 a Dictionaries ccc b aA Ba
L1=args m L1 a Dictionaries ccc b aA Ba
a=L1
a=Dictionaries
can't read "Dictionaries": variable is array
    while executing
"set v $Dictionaries"
    ("eval" body line 1)
    invoked from within
"eval set v \$$a"
    (procedure "xloc" line 18)
    invoked from within
"xloc a aA b Ba ccc "
    (file "localtest" line 25)
bash-2.03$

ObservedBehavior:
First I do not understand why "info locals" does list the global variables. It seems to lists them as soon as they are referenced in the procedure. 

Second: The example works in tcl8.0 but not in 8.3. If I put the line
    global Dictionaries

down into the foreach loop it works as a workaround:
    foreach a [info locals {[a-zA-Z]?*}] {
        global Dictionaries
        puts "a=$a"
        eval set v \$$a
        set Dictionaries($a) $v
    }

This is an extract out of a running program since 7.6. In 8.0 the error does not cause trouble but under 8.3 it crashes.

DesiredBehavior:
I would expect the varables listed in the global statement not to be
listed by "info locals" at all.
dkfplain2000-11-15 21:58:10
[info locals] lists the variables that are visible in the current context.  All [global] does is create a local alias for each named global variable with the "same" name as the global variable (it doesn't work quite like that if you put in namespace qualifiers, but that's a separate story.)  This is not a bug, or certainly not a functional one.  Maybe a documentation change would help instead?
dkf Closed ticket [219387ffff]. [History diff]2000-11-21 22:56:43
mziplain2000-12-01 19:19:52
I have the same problem and can't understand the differences between info locals and info vars. In the release 8.3.2 there is not a difference.
Marc Ziegenhagen
dkfplain2000-12-01 20:56:43
There is a difference when you consider passing in search patterns with namespace qualifiers.  [info locals] only finds variables in the current naming context, [info globals] only finds variables in the global naming context, and [info vars] finds variables in either the current naming context or any named one (with qualifiers added.)  The difference is admittedly slight, but it is significant.  The current behaviour is also correct and documented correctly.
dgp Ticket [219387ffff]: 1 change [History diff]2001-04-04 12:44:03
dgp Ticket [219387ffff]: 2 changes [History diff]2001-04-04 12:44:04
dgpplain2008-08-29 21:08:52
Logged In: YES 
user_id=80530
Originator: NO


The doc change noted here (from a
2000-11-21 commit!) has been flagged
on comp.lang.tcl as incorrect.

Is there any recollection beyond
what's recorded here how that
change came about, and how it came
to be incorrect?
dkfplain2008-08-29 21:20:35
Logged In: YES 
user_id=79902
Originator: NO

I've no idea; I've forgotten everything about this bug that I ever knew.

At a guess, someone seems to be wanting [info locals] to not return linked variables. If they want stuff that's been brought in by [upvar] but not by [global], I don't want to know.

I have no plans to do anything about this bug. The world hasn't ended.
dgp Ticket [219387ffff]: 1 change [History diff]2008-08-29 21:50:39
phoinix77plain2008-08-29 22:51:29
Logged In: YES 
user_id=2176213
Originator: NO

Please close this ticket.

I was the original submitter of this ticket.
I understand the philosophy behind the behaviour as you explain it.
It is just annoying as we still have the mentioned program running on 8.0,
but I will eventually change it as we have the most of our programs now converted to run on 8.5.

Christian Eva
dgpplain2008-08-30 02:48:00
Logged In: YES 
user_id=80530
Originator: NO


Ok the history is messy on this one.

Tcl 8.1.0 had a bug in [info locals].
That's the bug reported here, since
it was still present in Tcl 8.3.2.

The reaction was to (partially, vaguely)
document the bug instead of fix it.  That
was the docs change added for Tcl 8.3.3.

This got reported again as 567386.  It
was fixed in Tcl 8.4b1 and has been fixed
ever since.  [info locals] is once again
compatible with Tcl 8.0 and Tcl 7.* behavior.
Been fixed since the 2002-06-11 commit by
Miguel Sofer.

The remaining flaw is that we never yanked
the documentation error back out.  That's
the task for us now.
phoinix77plain2008-09-27 21:21:29
Don,
Thanks very much to dig that out and clarify, it is much appreciated!

And the good thing is our program actually works fine now with Tcl8.4.19 and 8.5.2.

I think I gave up on it when the first release of Tcl8.4 did not work.

Christian Eva
dgp Closed ticket [219387ffff]. [History diff]2008-09-30 01:38:13
dgp Ticket [219387ffff]: 2 changes [History diff]2008-09-30 01:38:14
Log in (anonymous is fine) to add a comment.