const Propagation
Julian Kranz via Digitalmars-d
digitalmars-d at puremagic.com
Mon Dec 29 07:17:27 PST 2014
Thank you for your answers. All of your suggestions go into the
right direction, however there's still one thing left that
breakes it: the method itself (blah()) needs to be marked as
const to be callable on a const object. Therefore, I need
something like
void blah(...)(...) if(this ia const object) const : nothing {
}
I would also like to discuss the underlying problem. Even if we
end up finding some syntactic monster to deal with this, there
obviously is no sneaky syntax for it. Am I wrong thinking that is
some very basic type checking problem? I mean, D already
implements const transitively. Thus, if I cast some object to its
const version, all its members magically turn to be const as
well. Wouldn't it be natural to apply this here as well? This
way, I would not even need to declare the lambda's parameter as
const or anything; the compiler would only fail if I actually
pass in something of which the compiler is unsure whether it
changes the passed-in object or not...
More information about the Digitalmars-d
mailing list