Clarifying 'const' terminology
Sean Kelly
sean at f4.ca
Sat Jul 8 19:51:08 PDT 2006
Derek Parnell wrote:
> On Sun, 09 Jul 2006 08:03:52 +1000, Sean Kelly <sean at f4.ca> wrote:
>
>
>
>> In the realm of compiler optimization techniques, there's another
>> issue as well: can the compiler assume that, because it is evaluating
>> a const reference, that the underlying data will not change while that
>> reference is in use.
>
> Just to clarify, are you saying that while a function that was passed a
> 'const' reference is running, can the compiler assume that so other
> concurrently running function will change the passed data?
Yes, be it in another thread or merely called through an opaque function
pointer inside the const-qualified code. But at some point I think the
user simply has to promise not to be evil so the compiler can go on with
its job. I'm just not sure exactly where the line should be drawn.
Sean
More information about the Digitalmars-d-learn
mailing list