inout/out static array parameter
Derek Parnell
derek at psych.ward
Tue Feb 21 19:15:32 PST 2006
On Wed, 22 Feb 2006 03:02:22 +0000 (UTC), Tom wrote:
> Why is this illegal? Where does the documentation states this?
> Does it have something to do with the matter that int[10] is allocated onto the
> stack? Sometimes I think D losses its abstraction capability when one has to be
> concerned about this kind of differences.
>
> 5# void f(inout int[10] x)
> 6# {
> 7# x[0..$] = 99;
> 8# }
>
> test.d(5): cannot have out or inout parameter of type int[10]
I cannot see why D should be upset with this. The implementation would be
just be passing the address of the int[10] array, just as it does for 'in'
parameters. In conceptual terms, it is identical to this, which D does
allow ...
struct X
{
int[10] x;
}
void f(inout X q)
{
q.x[0..$] = 99;
}
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
22/02/2006 2:07:00 PM
More information about the Digitalmars-d
mailing list