[Issue 12282] Immutable result of std.array.array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 9 14:26:15 PDT 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12282



--- Comment #2 from bearophile_hugs at eml.cc 2014-03-09 14:26:13 PDT ---
(In reply to comment #1)

> I'm not closing, because it is a valid request, but I don't see any way of
> making it happen.

Thank you for your answers :-) In general if a request is impossible there's
not much sense in keeping it open. But let's keep this open for some more time.


> const(int[]) array(              ) pure {return (int[]).init;}
> const(int[]) array(const(int[]) p) pure {return p;} 
> ```
> 
> Currently, 1) and 2) pass, but 3) fails. For a good reason.
> 
> So, unless the language gives us some sort of "noalias" for the return value,

If you have a function like this:

int[] array(scope const int[] a) pure {}

Or even like this:

int[] array(scope int[] a) pure {}

The input is const, so it can't be mutated, ints don't have indirections, and
"scope" once implemented means the input data can't escape the array function.
Is this enough to be able to cast the result to immutable?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list