Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2010-08-07
16:35 • Closed ticket [3041099fff]: dict variable check missing? plus 7 other change... artifact: e79dc2d279 user: ferrieux
09:26 • New ticket [3041099fff]. artifact: 2fff2ce398 user: tombert

dict variable check missing?

Closed / Invalid3041099fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 16 years ago
Descriptionplain2010-08-07 09:26:43
Create a dictionary
>  set mydict [dict create -range {-values {a b c} -base k}]
-range {-values {a b c} -base k}

Manipulate dictionary the correct way:
>  dict set mydict -range -base M
-range {-values {a b c} -base M}

Manipulate dictionary the wrong way:
>  dict set $mydict1 -range -base M
-range {-base M}

In my point of view there should be a check throwing an error when doing it the "wrong way".

Regards
thomas
ferrieuxplain2010-08-07 16:35:01
In Tcl, everything is a string, and just about every string is a valid variable name.
So, whatever $mydict1 is at the time, it is nevertheless a potential varname, that can legally hold the dict value you're creating with [dict set]. The fact that it contains spaces, which is likely if it's also a dict value, doesn't allow the Tcl runtime to dismiss it:

   dict set "foo bar" a b

   set "foo bar"
   -> a b

   dict get [set "foo bar"] a
   -> b
Log in (anonymous is fine) to add a comment.