On 2014-02-25 01:08:47 +0000, Tofu Ninja said:
On Tuesday, 25 February 2014 at 00:55:55 UTC, Tofu Ninja wrote:
Also, in some cases it is not enough just to ensure that it is called,
some times you will want to make sure that it is called at the
beginning or end of the function. Though this is harder to get right,
not really sure how it would work with returns.
In the case where it would be needed to be called at the beginning or
the end of the new method. The compiler might be able to implicitly add
it in itself, similar to how super(); is implicitly added to the
beginning of overridden constructors.
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.
-S.