"multi morphic" classes
BCS
BCS at pathlink.com
Fri May 2 11:21:35 PDT 2008
pragma wrote:
> That in turn opens the door for a kind of AOP
It's neat that it could get that. I had some nebulous thoughts in that
direction but don't known enough about it to really comment.
I think programming for that would result in some interesting code (LOTS
of SMALL methods).
>
> Anyway, by implementing the a vtbl in plain code, you have the ability
> to manipulate it on the fly. Were each instance allowed to have it's
> own personal copy of that table, all kinds of modifications become
> possible.
I wasn't really thinking of vtbl per instance but that would provide
some interesting effects. I guess with the right construct you could
take any object and, on the fly, replace it's vtbl with a copy and then
muck around to your harts content.
After thinking a bit more I think the privative that woulds be needed
would work something like this
// get a "type structure" that is a copy
auto tmp = this.dynamic_typeof.dup;
// set members
tmp.methoud!(bar) = (int i)
{
writef("bar called with %d\n", i)
// get the old memebers
return tmp.methoud!(bar)(i);
};
// set the instances type
this.dynamic_typeof = tmp;
More information about the Digitalmars-d
mailing list