Hi D',

I agree whatever you are saying. 
But i need to support somebody's code without annoying users by breaking their old 
code which depends on this interface.

Yes, i can expand the scope of the routine now and let users pass in the additional 
information.
But again if i can guess it somehow, why to make it mandatory in the interface.

-Sharad  

> -----Original Message-----
> From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, October 22, 2003 8:53 PM
> To: Gupta, Sharad
> Cc: [EMAIL PROTECTED]
> Subject: Re: FQN from references
> 
> 
> Gupta, Sharad wrote:
> > I can't store it somewhere. I have a routine to which a 
> user can pass a coderef.
> > And in that routine i want to know the full name of that coderef.
> > 
> > -Sharad
> 
> But in that case isn't it just a design issue, to me it would 
> make more 
> sense to pass the name of the routine and call it directly from the 
> symbol table rather than passing the code ref, or pass both 
> the ref and 
> its' name, since they are really independent pieces of 
> information you 
> don't *need* one to use the other, it would limit the ability 
> of the sub 
> if you are passing a code ref, and it is expecting a code ref 
> & and sub 
> name in the same argument, since presumably if you want the 
> code to call 
> it as a subroutine an anonymous code ref should work in the 
> same manner 
> as any other code ref, but it won't have a name, so you are really 
> wanting "a code ref with a name" as your argument, but at 
> that point it 
> makes more sense to break that into "a code ref, and a name"....
> 
> But then, obviously I haven't seen the rest of the code......
> 
> http://danconia.org
> 
> > 
> > 
> >>-----Original Message-----
> >>From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
> >>Sent: Wednesday, October 22, 2003 6:23 PM
> >>To: Gupta, Sharad
> >>Cc: [EMAIL PROTECTED]
> >>Subject: Re: FQN from references
> >>
> >>
> >>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
> >>
> >>
> > 
> > 
> > 
> 
> 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to