why no '->' operator?

Michael Weber mweber1488 at gmail.com
Wed Jan 31 21:40:42 PST 2007


I have used D for a few months now and its the best thing I have found since C++. However, there are a number of things that bother me about D. I am not getting into all of them just my qualms about the arrow operator. I, for one, do not see a reason why it was not included. Here is a reason why it should be included:

struct TestStruct {
        int a,b;
}
TestStruct[]* ts;
ts.length = 1;
ts[0].a = 3;

The dot operator is supposed to resolve the structure pointer and assign a to be three but this wont compile because the compiler thinks that a is a property of arrays and not a member of the structure. Instead I have to do this:

(*ts[0]).a = 3;

It would be easier to just have to do ts[0]->a =3; and be done with it.



More information about the Digitalmars-d mailing list