Immutable and unique in C#

deadalnix deadalnix at gmail.com
Mon Nov 12 15:52:46 PST 2012


Le 13/11/2012 00:46, Walter Bright a écrit :
> On 11/9/2012 5:53 AM, Sönke Ludwig wrote:
>> Independent of this article I think D is currently missing out a lot by
>> omitting a proper unique type (a _proper_ library solution would be a
>> start, but I'm not sure if that can handle all details). It would make a
>> lot of the cases work that are currently simply not practical because of
>> loads of casts that are necessary.
>
> Unique as a type qualifier comes with all kinds of subtle problems. For
> one thing, unique is more of a property of an expression rather than a
> property of the type.
>
> But I was thinking - what if it's a storage class? Like ref is? Working
> through the use cases in my head, I think it can work. Unique being a
> property of an expression, this can be tested upon assignment to the
> unique variable. Upon reading that unique variable, the value of it is
> erased.
>
> Function parameters can be qualified with "unique" as well, meaning
> their corresponding arguments can only be unique expressions.
>

As much as I like the unique proposal, I don't think it is a good idea 
to integrate at this point.


More information about the Digitalmars-d mailing list