opDot == alias this?
Simen Kjaeraas
simen.kjaras at gmail.com
Wed Jul 18 10:07:12 PDT 2012
On Wed, 18 Jul 2012 16:58:34 +0200, Namespace <rswhite4 at googlemail.com>
wrote:
> First:
> Why is opDot not listed here: http://dlang.org/operatoroverloading.html ?
> How much other operators exists which are not listed there?
I believe it's being deprecated. As far as I know, no other operators are
unmentioned.
> Is opDot the same as alias this? I think so.
They are related, but not the same. opDot allows access to the returned
type's
members and functions, but not the type itself.
> What are the advantages and disadvantages of both?
alias this allows implicit type conversions, opDot does not. That's about
it,
I think.
> Which of them should i use?
Depends. Look above. If you want a type to be usable as if another type,
use
alias this. If you just want to be able to access members of the other
type,
use opDot.
> Will one of them disappear in the future?
As stated above, I believe opDot is scheduled for deprecation, but I'm
unsure if
(not to mention when) it will happen.
> I think opDot is more flexible as alias this. You can have one alias
> this for one class/struct, but various opDot's, as this example shows:
TDPL states that multiple alias this should be supported, but it has not
yet
been implemented in the compiler.
--
Simen
More information about the Digitalmars-d-learn
mailing list