Logical const

Fawzi Mohamed fawzi at gmx.ch
Thu Dec 2 03:36:15 PST 2010


On 1-dic-10, at 22:18, Steven Schveighoffer wrote:

> 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.

indeed that is one of the main things that I want from logical const:  
being able to store/memoize values in a structure, not outside it.
It is ok to have to jump some hoops to get it, but it should be  
possible (casting that is guaranteed to work in some clearly defined  
circumstances would do it for example).

Fawzi



More information about the Digitalmars-d mailing list