|
From: | Shai Ayal |
Subject: | Re: Finding out the name of the dispatched function |
Date: | Wed, 19 Apr 2006 22:22:38 +0300 |
User-agent: | Thunderbird 1.5 (Windows/20051201) |
Paul Kienzle wrote:
On Apr 16, 2006, at 1:49 AM, Shai Ayal wrote:My question was not clear -- consider the following example with the theoretical function HowWasICalled:function xxx disp(["--> ",HowWasICalled()]); endfunction dispatch("yyy","xxx","any"); dispatch("zzz","xxx","any"); xxx --> xxx yyy --> yyy zzz --> zzzIs the a function which does what HowWasICalled does? A function like this would allow a single function to be reused. An immediate example which springs to mind is a generic warning function:function gen_warn warning("%s is depreciated\n",HowWasICalled()); endfunction dispatch("set","gen_warn","any"); dispatch("gset","gen_warn","any"); and so onNo, this is not supported. Nor do I see an easy way to support it. You could hack dispatch.cc so that it would do the right thing when the function is called via dispatch by pushing the variable 'base' before dispatching in dispatch.cc(do_multi_index_op) and popping it after return. Then HowWasICalled could return the top of this stack. However, this would not return the correct result if not called via dispatch, and would slow down dispatch even if the facility wasn't used.
So, to sum it up a feature like this would: 1. be hard to implement 2. have non-consistent behavior 3. slow-down dispatch OK than I think maybe I'll just forget about it :) Thanks, Shai
[Prev in Thread] | Current Thread | [Next in Thread] |