Immutable and unique in C#

Sönke Ludwig sludwig at outerproduct.org
Tue Nov 13 03:03:29 PST 2012


Am 13.11.2012 09:40, schrieb Walter Bright:
> 
> #2 is the interesting bit. That requires some compiler support, sort of like:
> 
>      __unique(Expression)
> 
> which will allow it through if Expression is some combination of new, pure functions, and other
> Unique pointers.
> 

I just realized that using __unique(expression) vs. verifying the type must be unique is not really
mutually exclusive. Unique!T (or Isolated!T) could simply support both. It could still expose plain,
immutable or Isolated!T data fields and could still allow pure methods that only have these kinds of
parameters to be called. So performing one-time reads is, even in that case, only necessary for
certain operations.


More information about the Digitalmars-d mailing list