uniqueness

Don nospam at nospam.com
Fri Dec 10 02:53:04 PST 2010


Fawzi Mohamed wrote:

> If one could declare return or out types as unique (note that unique is 
> *not* part of the type, it is like the storage attributes), these 
> methods could be implicitly castable to const or immutable, allowing 
> nicer code.
> 
> Constructors *might* return unique objects (an object is unique only if 
> all its references are to unique or immutable objects).
> 
> In several cases uniqueness could be checked by the compiler. I think 
> that such a change would improve part of my code, removing the need for 
> several spurious casts, while at the same time making the code safer.

Any mutable object returned from a strongly pure function, is guaranteed 
to be unique.


More information about the Digitalmars-d mailing list