Re: FQN from references

From: Wiggins D'Anconia (wiggins_at_danconia.org)
Date: 10/23/03


Date: Wed, 22 Oct 2003 20:22:47 -0500
To: "Gupta, Sharad" <Sharad.Gupta@netapp.com>

Gupta, Sharad wrote:
> Hi All,
>
> How do i know the full name of a variable from its reference??.
>
> Say i have a routine defined like this:
>
> package Bar;
> sub foo {};
>
> And then i say:
> my $x = \&foo;
>
> Now from this coderef ($x) i want to know its fully qualified name which would be somthing like Bar::Foo.
> Is there a way to do that.??.
>

Where do you want to know it? Presumably if you have set it then you
should know it already, if it is set dynamically you still have to have
the name somewhere that you can access, then it is just a matter of
storing it smartly, aka rather than using

my $x = \&foo;

Why not:

my %handler;
$handler{'Bar::Foo'} = \&foo;

Now you can access the reference and have its name at the same time. The
problem comes in with inheritance because maybe $y wants to call $x
(foo) and thinks it is in Bar but it really is in Baz, does this mean it
shouldn't be called, or just that it was inherited and it is ok to call?

Within foo, there is __PACKAGE__ which will give you Bar...

You may also want to have a look at Symbol Tables in perldoc perlmod....

Gurus, am I missing out on something?? ;-)

http://danconia.org



Relevant Pages

  • FQN from references
    ... How do i know the full name of a variable from its reference??. ... Say i have a routine defined like this: ... sub foo; ...
    (perl.beginners)
  • Re: ECMAScript standard:the code(s) for figure on page 3 ?
    ... Foo.prototype and Foo.prototype and value of "this" is reference to ... Inheritance in these languages is facilitated by having ... That reference is assigned to `bar', ... properties who's "Object instance properties" like init in Foo. ...
    (comp.lang.javascript)
  • Re: How to find Me in a library procedure
    ... For Shared methods that is correct; for instance methods the object ... If he compiles and marks those methods not to be inlined, he could possibly get a reference to the "Me" object he seeks, although that might require a debugger to be attached. ... Inheritance simply would not work with TextBox and ComboBox because ...
    (microsoft.public.dotnet.languages.vb)
  • Re: using-directive question
    ... behave as I would have expected. ... > the language features, and if you have a specific question about a ... because I don't understand why the inheritance of a virtual function ... You can have a reference for the library (and there are excellent ...
    (comp.lang.cpp)
  • Re: Replacing new?
    ... var a1= new A; ... The difference is when you try inheritance. ... B's this keyword will be a reference to the global ... Closures, of themselves, don't necessarily cause memory leaks. ...
    (comp.lang.javascript)