On 2014-02-25 10:23:31 +0000, Steve Teale said:

On Tuesday, 25 February 2014 at 03:13:23 UTC, Shammah Chancellor wrote:
So far as I'm understanding this thread, Steve Teale is asking for a way to inject code before and after a call to a function from other places in the program. E.g. Write some function foo, write some function bar, and specify that any time foo is called, bar should be called immediately after *automagically*.

The reason this hasn't been done in any language I'm aware of is because you can solve the same problem using existing polymorphism, and it's a horribly awful design practice to have hidden code like that.


It's a bit more specific than 'from other places in the program', and anyway, once you've accepted virtual functions, you've accepted 'automagic' ;=)

I'm writing a little example program that illustrates what I'm getting at, and I'll post it somewhere when I'm through.

Steve

If I was understanding properly, you were suggesting that the code should be executed even for instances of the base class. There's some automagic that's good, that sounds like a vile thing to have to debug when you take over for somebody else.

-S.

Reply via email to