RFC: scope and borrowing
bearophile via Digitalmars-d
digitalmars-d at puremagic.com
Tue Sep 23 04:11:36 PDT 2014
Steven Schveighoffer:
>> int[] foo(unique int[] a) pure {
> ...
> I don't think so. Strong pure function optimizations would not
> work for something like:
>
> auto x = foo(a) ~ foo(a);
This is similar to:
unique x1 = foo(a);
unique x2 = foo(a);
unique x = x1 ~ x2;
When the call to the first foo ends you have a x1 reference to
the array data. Such reference x1 is unique, so now 'a' is not
usable any more, you can't pass 'a' to foo once more.
I need to learn more about such stuff of linear typing.
Bye,
bearophile
More information about the Digitalmars-d
mailing list