Anno has asked for the wisdom of the Perl Monks concerning the following question:
it should return an array ref, but called as@{ gimme_a_ref() } = ( 1, 2, 3);
$gimme_a_ref->{ haha} = 'hihi';
it should return a hash ref, and so on. In non-dereferening calls let it return undef.gimme_a_ref()->{ haha} = 'hihi';
I realize that gimme_a_ref() would be useless without further properties, like behaving sticky and returning the same ref after the first call, but that's not the point of my question. I wonder how I could find out in what de-referencing context, if any, I was called.
I notice there are opcodes for the various types of de-referencing, like OP_RV2AV for arrays, etc. I guess I'd have to search the op tree "above me" for one of these, but how would I go about that?
Anno
Update: (Unfortunate, because misleading) mistyped example corrected.
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Autovivifying XS routine
by ikegami (Patriarch) on Jun 01, 2007 at 14:42 UTC | |
by Anno (Deacon) on Jun 01, 2007 at 15:01 UTC | |
|
Re: Autovivifying XS routine
by shmem (Chancellor) on Jun 01, 2007 at 15:30 UTC | |
by Anno (Deacon) on Jun 01, 2007 at 15:48 UTC | |
by shmem (Chancellor) on Jun 01, 2007 at 16:11 UTC | |
|
Re: Autovivifying XS routine
by BrowserUk (Patriarch) on Jun 01, 2007 at 15:00 UTC | |
by Anno (Deacon) on Jun 01, 2007 at 15:27 UTC | |
by BrowserUk (Patriarch) on Jun 01, 2007 at 15:49 UTC | |
by Anno (Deacon) on Jun 01, 2007 at 16:07 UTC | |
by BrowserUk (Patriarch) on Jun 01, 2007 at 16:53 UTC | |
|