several questions
Saaa
empty at needmail.com
Sun Feb 17 07:13:20 PST 2008
"Bill Baxter" <dnewsgroup at billbaxter.com> wrote in message
news:fp9ih7$29av$2 at digitalmars.com...
> Saaa wrote:
>> But if I use a ref or a pointer, the function is allowed to change the
>> variable.
>> Using 'in' will make a copy?
>
> For D1, in is the same as nothing at all. In D2 I think in is the same as
> 'invariant'. So yeh, it will make a copy.
>
>> I thought ref was just a renaming of 'inout'.
>> But there is no way to only pass a reference without giving the function
>> write permission?
>>
>> I sent a lot of big arrays in structs, so I think this is kind of crucial
>> for me :/
>
> No way in D1. Yes way in D2 (const ref or invariant ref should work in
> latest DMD).
Thanks! This is really good to know. Now I understand why they changed inout
to ref.
This will greatly optimize my program as I use a LOT of big static arrays in
structs.
I'll use ref from now on for every passing of one of those :)
More information about the Digitalmars-d-learn
mailing list