On Wed, 18 Nov 2009 14:03:11 -0500, Bartosz Milewski
<bartosz-nos...@relisoft.com> wrote:
Andrei Alexandrescu Wrote:
One thing that Bartosz didn't mention is that "this unique" is different
than "the other unique", which I think reveals the half-bakedness of the
proposal. "The other unique" that was intensively discussed before is
transitive, meaning that the root reference points to a graph of objects
having no other connection to the outer world. "This unique" is very
different because it's shallow - only the array chunk is unaliased, but
the members of the array don't need to be. This is a very important
distinction.
Actually I was thinking of deep unique, but understandably I neither
described full details of my proposal, nor have I completely "baked" it,
which would require some serious work and a lot more discussion. One of
these days I will blog about uniqueness in more detail.
The problem of transitivity with respect to arrays has been discussed
before in the context of const and immutable. We realized that shallow
constness/immutability would be useful in some scenarios but, because of
the added complexity, we punted it. My feeling is that, similarly, in
most cases the restriction that a unique array may only hold unique
objects is not unreasonable.
I wonder what your expert opinion is: Is something like unique possible
without introducing all the other type modifiers (like 'lent', etc.)? If
not, what are the minimum type modifiers you'd need to get unique to
work? I really like the unique concept, and think it is really one of the
biggest holes missing from the const system (aside from bug 1961).
-Steve