peculiarities with char[] and std.string

Kyle K Kyle_member at pathlink.com
Mon Jun 19 07:19:04 PDT 2006


In article <e76aq8$qsr$1 at digitaldaemon.com>, xs0 says...
>Well, you didn't touch the memory you didn't allocate :) If you had
>
>char[] bob(in char[] str)
>{
>     str[0] = 'a';
>     return str;
>}
>
>You'd get "aoo:aoo" as output (or a crash, as you can't write into 
>constants on some platforms)

Ah ok, that makes sense. So using 'in' with arrays and aggregate types will
always still give you a reference? I assume with primitives the semantics remain
pass-by-value, such that foo(in int b) will never modify the caller's data?


>
>Hope that helped :)

It did, thanks a lot! :D





More information about the Digitalmars-d-learn mailing list