Trouble with anon delegates.

BCS BCS at pathlink.com
Wed Jan 17 11:22:43 PST 2007


Pragma wrote:
> BCS wrote:
> 
>> Reply to Pragma,
>>
>>>
>>> auto rule = ws >> '(' >> +Argument >> ')' >> { writefln("args
>>> parsed"); };
>>>
>>> It works fine for this kind of stuff, but once you graduate beyond
>>> there and want to bind terminals to class members, you need the
>>> ability to perform filtering and aritmetic on them.  But once you do
>>> that, you find that your stack frame is all out of whack. :(
>>
>>
>> I tend to use structs for that kind of thing. They entail less 
>> overhead than classes.
> 
> 
> I would have done the same, but I'm making heavy use of polymorphism to 
> get the operators to work as expected.  However, that could be 
> refactored into a struct-oriented design with some clever templates and 
> mixins to emulate inheritance.

Ah, you must be doing something more complicated than I was thinking of. 
I often find myself using the pattern of a struct that is used in 
exactly one place:

struct S
{
	int i;
	int j(){return i}
}

auto s = new S;
s.i=2;
return &s.j

this can be done with a class, but it has some more overhead.

class C
{
	int i;
	this(int k){i=k;}
	int j(){return i}
}

return &(new C(1)).j

>>
>> (Where's the 2.0 wish list?  <g> )
>>
> 
> You mean, we dont' have one yet?!
> 

Not that I know of :-|


More information about the Digitalmars-d-learn mailing list