OO syntax

bearophile bearophileHUGS at lycos.com
Wed Oct 13 15:26:13 PDT 2010


spir:

> Does this OO-like syntax also work with other parameter types?

No, it currently doesn't.


> Else, why not? I mean, also, why allow it for arrays?

It was originally a compiler bug relative to just arrays. Some people have appreciated it, and it became a feature.
Some people have asked to extend it to all other types, and maybe this will be implemented, but if you mix it with operator overloading, it gives syntax problems. You have to design such shortcuts with a lot of care, because they are a bit handy, but they may have serious side effects. Often keeping the syntax more clean, with less magic, is the safest and wiser thing to do.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list