how you build your dict determines how you can access it. why?
Mar 21 2014 | 2:13 am
Putzing around with some nested dicts today, and I noticed something slightly odd, or at least it doesn't make sense to me -- if a dict guru can explain the reasoning, I'd love to know. in brief:
-- if you build nested dicts using the 'replace' message (replace foo::bar::pi 3.14) you can fish that data out with a get message to a dict. The message "get foo::bar::pi" sent to a dict will return 'foo::bar::pi 3.14', but if you send the message 'dictionary pi' to a [dict.view], you'll get an error in the max window.
Bonus: Try dict.unpack in the same situation, and you get this: dict.unpack: unable reference dictionary named _4#%
-- If you build an identical structure using a bunch of [dict.pack]s, the behavior is the opposite: sending the name of a sub-dict to [dict.unpack] works just fine, but 'get' messages using nesting fail. I've enclosed a demo patch for the curious.
Interestingly enough, if you do all your dict work in js, any dictionaries created in the script are accessible via either method. It seems to me that all ways of building these structures should have all ways of getting information out of them available. Intuitively, it feels like something is broken, but if there is a logic to it, then I'll shut up & figure out how to work around it...