[Design] return char[] or string?

Derek Parnell derek at psych.ward
Thu Aug 23 14:44:24 PDT 2007


On Thu, 23 Aug 2007 22:20:16 +0100, Stewart Gordon wrote:

> I suppose properties have less syntactical power, but more power in terms of 
> practical uses.  If that makes sense....

Yes I can see what you mean.

( silly example: )
    long x() } return { _x * 2 + _y; }
    void x(int y) { _x = y / 2; _y = y - 2; }
    void x(char[] y) { . . . }

    foo.x = 16;
    long A = foo.x;
    foo.x = "abc";
    long B = foo.x;
  
On the other hand, when I first read about properties I thought
"Brilliant!" and started using them. However it soon became apparent that
they were not brilliant but were really a PITA. I can't be bothered with
them now as they just increase the cost of maintenance, because they cannot
be syntactically be treated as the fields that they look like. They deceive
coders because they look like fields but they are not fields.

In short, properties in D are evil in the same way that 'goto' is evil. If
you use them, be prepared to pay extra for them.

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell


More information about the Digitalmars-d-learn mailing list