RFC: scope and borrowing

via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 23 03:16:25 PDT 2014


On Tuesday, 23 September 2014 at 09:17:48 UTC, bearophile wrote:
> Marc Schütz:
>
>> http://wiki.dlang.org/User:Schuetzm/scope
>
> If a mutable argument of a function is tagged as unique, the 
> type system guarantees that there are no other references to 
> it. So can a function 'foo' like this be "strongly pure"?
>
>
> int[] foo(unique int[] a) pure {
>     a[0]++;
>     return a;
> }

I think so. But note that `unique` is not part of my proposal, I 
merely used it in the example. I think it could be implemented 
relatively easily, because DMD internally already has a concept 
of uniqueness that is used for converting things to immutable 
implicitly. But this would be a different proposal.


More information about the Digitalmars-d mailing list