Logical const

Steven Schveighoffer schveiguy at yahoo.com
Wed Dec 1 13:18:34 PST 2010


On Wed, 01 Dec 2010 11:49:36 -0500, so <so at so.do> wrote:

> On Wed, 01 Dec 2010 18:38:23 +0200, so <so at so.do> wrote:
>
>> Since i called it a bad design, i am entitled to introduce a better  
>> design.
>>
>> interface renderer {
>> 	void draw(rect rects, size_t n);
>> }
>>
>> class widget {
>> 	void draw(renderer r) { ... }
>> }
>
> Pfft sorry for that abomination!
>
> interface renderer {
> 	void draw(rect[] rects);
> }
>
> class widget {
> 	rect r;
> 	window owner;
> 	void draw(renderer) const { ... }
> }

This requires you to store the widget-renderer relationship outside the  
widget.  Since each widget has exactly one location where it lives, this  
is awkward.  Much better to just store the relationship on each widget.

-Steve


More information about the Digitalmars-d mailing list