From: Oren Ben-K. <or...@ri...> - 2002-05-19 20:32:44
|
I just spent a few hours chasing my tail wrt. the model section, node identity, and so on. Ouch. BTW, this has made me appreciate Clark's formulation of the model section even more. This is *hard*. Anyway, after several unsuccessful trials to put things down on paper so that they made sense, I came upon the following insight. The whole meanigful/meaningless alias issue doesn't hang around the matter of node identity... or rather, the right way to look at it is one level deeper. The real issue is about node *mutability*. Obviously in a read-only graph there's no reason to distinguish between identical and merely equal nodes. And, even in a mutable data structure, the same holds for type families describing immutable values. Take integers for example. You can't *change* the value 7; you can just create a new value (say, 6) and stuff that into your variable instead. Likewise strings in Perl/Java/Python. You can't change a string (in place). You can just create a new one and stuff that into your variable instead. In contrast, if you have an array, you can change the value stored in its first element. Hence keeping track of identical vs. merely equal arrays is vital. So, what I'm going to do is erase a lot of messy wording and replace it with the following type family property (I'll word it better, promise :-): mutable: yes/no - For immutable type families, it is OK to wreak havoc with the alias structure (make all equal nodes identical, convert identical nodes into separate equal copies, etc.) without changing the semantics of the native model (though some representations are obviously more memory efficient than others). - For mutable type families, alias structure is sacred, and must always be preserved. - Most collections are mutable and most scalars aren't. - When in doubt (unknown type family), treat it as if it is mutable, just to be on the safe side, even if it is a scalar. Thoughts? And, BTW, great YAML meeting. I really wish I could have been there. Have fun, Oren Ben-Kiki |