[Issue 12282] Immutable result of std.array.array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 9 14:37:21 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12282
--- Comment #3 from monarchdodra at gmail.com 2014-03-09 14:37:18 PDT ---
(In reply to comment #2)
> 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,
Isn't it only const with "in" ? Not that it makes an actual difference here.
> Is this enough to be able to cast the result to immutable?
Actually, maybe. It's the "help from the compiler, and the language itself" I
was talking about, and the "noalias" type qualifier.
> ints don't have indirections, and
> "scope" once implemented means the input data can't escape the array function.
I'm not fluent with how `scope` would work, but I fear it would not work for
generic types, which may themselves have indirections.
Would this be legal? Or would it violate the "scope" constraint?
int*[] array(scope int*[] a) pure {}
--
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