Suggestion: object const'ness
Hasan Aljudy
hasan.aljudy at gmail.com
Sun May 21 09:34:29 PDT 2006
I think you misunderstood me.
I'm ok with the current meaning of in/inout.
Derek Parnell wrote:
> On Sun, 21 May 2006 13:36:33 +1000, Hasan Aljudy
> <hasan.aljudy at gmail.com> wrote:
>
>
>> huh? if you pass an object reference as in you shouldn't be able to
>> manipulate the object?!!
>
>
> Why not? What is the axiom that makes this so?
>
>> In what sense is that a "true" in?
>
>
> There *is* no "true" 'in'. Each language has its own definition of
> 'in'. In D the 'in' just means you can't modify what ever has been
> passed to the function. And in the case of objects and arrays, it's the
> reference that is passed - thus you can't change the reference. There
> is nowhere that talks about protecting that which is referenced - only
> the reference itself.
>
> If we learn to live with this, we can design our code around such a
> concept.
>
> Personally, I'd like the compiler to be a bit more helpful so I could
> tell it when I'm not intending something to be changed and it could
> tell me when it happens to detect that I'm accidently trying to change it.
>
More information about the Digitalmars-d
mailing list