Accidentally killing immutable is too easy in D (Was: cast()x - a valid expression?)

Mehrdad wfunction at hotmail.com
Thu Jun 2 09:12:13 PDT 2011


> "you're only supposed to use it when you know what you're doing when you
> use it"
> Well, that's kinda the requirement for any feature, isn't it?... :P
> Well, kinda, I do know what you mean. Yes, one needs to properly learn
> how cast() works, but that doesn't mean it would not be better for the
> feature to be designed in a way that is easier to learn (and just as
> powerful to use), or actually, it doesn't mean that even if you do know
> how cast() works, that you are not still likely to make a mistake when
> using it.
> So pretty much I agree with Nick here. I think me and a few others have
> mentioned it in the past, that the way cast works makes it somewhat easy
> to trip over one's foot and cast away something that was not intended.
> This may be a bit more common now and in the future as people use more
> and more of the newer D modifiers (shared, immutable, etc.).

Yes, let's introduce immutable_cast(), const_cast(), shared_cast(), static_cast(), dynamic_cast(),
reinterpret_cast(), sounds like a good idea lol.


More information about the Digitalmars-d mailing list