Home > Archive > Tcl > October 2004 > namespace variable not seen by [info exists]
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
namespace variable not seen by [info exists]
|
|
| Rolf Schroedter 2004-10-29, 3:58 am |
| A namespace variable which is declared by [variable bar]
is seen by [info vars] but not by [info exists].
Is this a bug or feature ?
% set tcl_patchLevel
8.4.6
% namespace eval ::foo {variable bar}
% info vars ::foo::*
::foo::bar
% info exists ::foo::bar
0
% namespace eval ::foo {variable bar 1}
% info exists ::foo::bar
1
Rolf.
---------------------------------------------------------------
Rolf Schroedter, German Aerospace Center
Remove .nospam to reply: mailto:Rolf.Schroedter@dlr.de.nospam
| |
| Martin Lemburg 2004-10-29, 3:58 pm |
| Hello Rolf,
the explaination is really simple!
The "variable" command used only with a variable name, declares only
the variable, but does not set the variable!
The man page of "variable" tells:
"If no value is specified, the new variable is left undefined."
So - using ...
% variable foo
must cause ...
% info exist foo
0
But - using ...
% variable foo bar
bar
must cause ...
% info exist foo
1
A declared, but undefined variable will be reported by "info vars"!
That's all!
Best regards,
Martin Lemburg
Unigraphics Solutions GmbH - UGS The PLM Company
Rolf Schroedter <me@privacy.net> wrote in message news:<2ue68vF28sqaiU1@uni-berlin.de>...
> A namespace variable which is declared by [variable bar]
> is seen by [info vars] but not by [info exists].
> Is this a bug or feature ?
>
> % set tcl_patchLevel
> 8.4.6
> % namespace eval ::foo {variable bar}
> % info vars ::foo::*
> ::foo::bar
> % info exists ::foo::bar
> 0
> % namespace eval ::foo {variable bar 1}
> % info exists ::foo::bar
> 1
>
> Rolf.
>
> ---------------------------------------------------------------
> Rolf Schroedter, German Aerospace Center
>
> Remove .nospam to reply: mailto:Rolf.Schroedter@dlr.de.nospam
| |
| Rolf Schroedter 2004-10-29, 3:59 pm |
| Martin Lemburg wrote:
> Hello Rolf,
>
> the explaination is really simple!
After reading the docs I withdrawed my message,
obviuosly too late - withdrawal and reading ...
;-)
---------------------------------------------------------------
Rolf Schroedter, German Aerospace Center
Remove .nospam to reply: mailto:Rolf.Schroedter@dlr.de.nospam
|
|
|
|
|