On Wednesday, 2 April 2014 at 14:23:57 UTC, Ola Fosheim Grøstad wrote:
On Monday, 24 February 2014 at 08:41:06 UTC, Steve Teale wrote:
>
Yes. This is "inner virtual functions" as opposed to "outer virtual functions" (C++). The successor to Simula, BETA (http://daimi.au.dk/~beta/), has this. Simula has this in the constructor of a class (which syntactically is the body), but BETA has the concept everywhere:

somefunction:<(#
  statements1;
  inner;
  statements2;
#)

When you specialize a function/class the extra stuff you add is replacing the "inner" statement (and can provide it's own "inner").

I had gone some distance along that course. A virtual function to handle events examined the event to see if it could deal with it. If it could not, it called a 'specificHandler' virtual function. But that approach only works if you have a hierarchy of known depth, when specificHandler only gets called for the leaf classes.

Later, I have had the constructors of derived classes add a handler delegate to a list of potential handlers maintained in the base class. The actual handler in the base class is a final method that simply iterates that list until some derived class handles the event, or throws if none do.

But both of these approaches are clumsy compared to what I would like to see.

It would help if D had 'direct' class methods (as opposed to final or virtual), as then I think it would be more straightforward to generate the delegate list.

I'm pleased to see though that some other languages have noted this deficiency.

Steve

Reply via email to