Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

strange dict behavior

19 views
Skip to first unread message

Bezoar

unread,
Jun 3, 2012, 3:54:15 PM6/3/12
to
I was trying a recursive routine to pull out all the keys of a dict and the results differed depending on how I initialized the data in the dict. My results were the same if I accessed the value of a key first then got all the keys vs getting all the keys. A snippet below shows the situation on tcl8.6b2.

==== code ==
proc getType { typestring} {
string range [string range $typestring [string first " a " $typestring ] [string first " with " $typestring ] ] 2 end-1
}
set input [dict create home {} ]
dict set input1 home address { street1 "23 Ave" street2 "Suite 200" }
dict set input home address street1 "6543 Waldorf Plaza"
dict set input home address street2 "Suite 200"

foreach key { home { home address } { home address street1 } { home address street2 } } {
set rep1 [ ::tcl::unsupported::representation [dict get $input1 {*}$key ] ]
set rep [ ::tcl::unsupported::representation [dict get $input {*}$key ] ]
if { [ getType $rep1 ] ne [ getType $rep ] } {
puts "representation for key '$key' in input1 is [ getType $rep1 ] but same key in input is [getType $rep ]"
}

# puts "[format "%50s | %50s" [dict get $input1 {*}$key ] [ dict get $input {*}$key ] ]"
}

Bezoar

unread,
Jun 3, 2012, 4:00:14 PM6/3/12
to
This was a partial post please see the follow on post for complete question.
0 new messages