SPUG: Introspective parameters... Can a parameter know it's argument's name from the caller's perspective?

Joshua ben Jore twists at gmail.com
Sun Jun 29 20:55:22 PDT 2008


On Fri, Jun 27, 2008 at 5:22 PM, Michael R. Wolf <MichaelRWolf at att.net> wrote:
> A colleague just asked a question that's related to a question I've had for
> years, so here goes my question.
>
> Is there some way that a parameter can know the name of the argument from
> the perspective of the caller?

Yes, you can make some guesses about the names of passed values
provided you're ok with extending the code in Devel::Caller's method
for asking whether your code was called as a method or a function. In
general, this code is too ugly to live. You're adviced not to solve
this problem in Perl 5. The general solution will eat your brain and
only a handful of people on the planet will be able to maintain it.
code crashes.  They're hard to debug.  And I don't know how to do
lexicals.

Josh


More information about the spug-list mailing list