Writing const-correct code in D

Lionello Lunesu lio at remove.lunesu.com
Wed Mar 8 02:36:40 PST 2006


eeeeeeeeeeee, a pointer! I thought we got rid of those...

L.

"Kevin Bealer" <Kevin_member at pathlink.com> wrote in message 
news:duluq5$11ki$1 at digitaldaemon.com...
> Also, this is not full "C++ const", only parameter passing and const
> methods, which seems to be the most popular parts of the const idea.
> It seems like it should require more syntax that C++, but it only
> takes a small amount.
>
>
> When working with types like "int", use "in" - const is not too much
> of an issue here.
>
> The same is true for struct, it gets copied in, which is fine for
> small structs.  For larger structs, you might want to pass by "in *",
> i.e. use "in Foo *".  You can modify this technique to use struct, for
> that see the last item in the numbered list at the end.
>
>
> For classes, the issue is that the pointer will not be modified with
> the "in" convention, but the values in the class may be.
>
> // "Problem" code 





More information about the Digitalmars-d mailing list