Skip to content
Tcl Source Code View Ticket
Login

View Ticket

the "variable" command doesn't always initialize properly.

Closed / Invalid218146ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:53:44
OriginalBugID: 2122 Bug
Version: 8.1
SubmitDate: '1999-05-24'
LastModified: '1999-08-08'
Severity: MED
Status: Closed
Submitter: pat
ChangedBy: hobbs
OS: Windows 95
OSVersion: 8.1 and 8.0.4
Machine: X86
FixedDate: '2000-10-25'
ClosedDate: '1999-08-08'


Name:
John Baxter

ReproducibleScript:
The following are commands typed in wish and the responses (on Windows
    95).
    
    % variable x ""
    % puts $x
    
    % variable y "a"
    % puts $y
    a
    % namespace eval foo variable z ""
    % puts ${foo::z}
    can't read "foo::z": no such variable
    % namespace eval foo variable w "a"
    % puts ${foo::w}
    a
    %

ObservedBehavior:
The behavior with respect to the variable foo::z seems inconsistent with
    the other cases as well as with the man page on the "variable" command.

DesiredBehavior:
Initializing a variable with a value should make it readable.



This is a conceptual error, and the result is as expected and
documented.  The namespace eval, like normal eval, will concat
the args together.  This causes an empty string ("") to just
disappear.  The command doesn't fail because variable with just
one arg is acceptable.  The safer way to call namespace eval is:
   namesapce eval foo { variable z "" } 
-- 08/08/1999 hobbs
welch Closed ticket [218146ffff]. [History diff]2000-10-26 08:15:56
dgp Ticket [218146ffff]: 4 changes [History diff]2001-04-18 06:28:18
dgp Ticket [218146ffff]: 4 changes [History diff]2001-04-18 06:28:40
Log in (anonymous is fine) to add a comment.