On 04/10/2011 02:58 AM, Adam D. Ruppe wrote:
A note: since I posted last, I changed my mind on something, and
bearophile, I rather doubt you'll like it...

Before, it was drawRectangle(int x1, int y2, int width, int height);

Now, it is drawRectangle(Point upperLeft, Size size);

So, at the usage, you now need to put in some more parenthesis
and say what you mean:

painter.drawRectangle(Point(0, 0), Size(win.width, win.height));


Why did I do this? Well, consider the following:

drawRectangle(int x1, int y1, int x2, int y2);

(This is, in fact, the signature in Windows GDI, whereas Xlib
  user width/height.)


The types there are no different than the above, but meaning has
changed. I'd be ok with saying "RTFM" to avoid having to use
the structs.

But, RTFM doesn't let you overload it, whereas the types do. Now,
it can offer both

drawRectangle(Point upperLeft, Size size);

*and*

drawRectangle(Point upperLeft, Point lowerRight);

I'm sure you were thinking about named arguments for a moment
there about width/height vs x2/y2. I did too. But, named arguments
don't really exist in D (you can do them via library magic but not
without) so it's moot, and I don't believe named arguments would
offer the overloading possibilities, which I like. It can save
some math while being quite natural.

The Point struct also makes drawPolygon look a lot better, so
it's of general use.

That was about the first change I intended to do on my side, after reading your code :-) In addition to the practical side you describe well, Point (or maybe better Position) is a nearly necessary semantic/conceptual type on the user side.

Denis
--
_________________
vita es estrany
spir.wikidot.com

Reply via email to