POV-Ray : Newsgroups : povray.off-topic : Really strange design choices : Re: Really strange design choices Server Time
6 Sep 2024 13:18:34 EDT (-0400)
  Re: Really strange design choices  
From: Invisible
Date: 17 Dec 2008 08:07:04
Message: <4948f978$1@news.povray.org>
Invisible wrote:

> In other small-print, I discover that "composite" objects are explicitly 
> mutable. If you "copy" such an object, it merely copies the reference to 
> it. If you mutate the copy object, the original object sees the change 
> too. Fair enough...
> 
> ...except, wait a sec. So you're telling me I can MUTATE DICTIONARY KEYS??
> 
> This is highly interesting, since the keys of a dictionary must, by 
> definition, be unique. If you insert a key into the dictionary, it 
> checks to see if such a key already exists. If so, that key's value is 
> replaced, otherwise the inserted value becomes a new entry.
> 
> But wait! I can insert a new key, and then mutate it to match one of the 
> existing keys. How does *that* work?? Do we now have a dictionary with 
> two identical keys? Or does one of the keys get deleted? (Which requires 
> monitoring every single object mutation to check whether it's a key 
> somewhere.) Or...??

According to the reference page for he "eq" operator, two composite 
objects are "equal" if they point to the same data structure. In other 
words, PostScript seems to work on reference equality, not value equality.

Thus, a copy of a composite object is always equal to that copy, and two 
seperate composite objects are always unequal, regardless of what you 
mutate their values to.

Still a fairly strange design decision, but it doesn't seem *quite* so 
insane now... ;-)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.