...peek at want.xs shows an aweful lot of logic

Right. I disentangled the part that I'd need and ended up with (almost) half the code from Want.xs. Speed issues aside, that's not reasonable.

what happens if someone assigns the return from gimme_a_ref() to a scalar, and then attempts to dereference it later?

That would be no different from other autovivifying situations. You can say

my $x; $x->{hihi}->{haha} = 'hoho';
but you can't keep $x->{hihi} for later, as in
my $x; my $y = $x->{hihi}; $y->{haha} = 'hoho';
So I'm not worried much about that effect, but the autovivifying option is out for the reason above.

Alter is already using ..., two levels of inside-out-style dereferencing

It's not quite as bad. Alter::ego is one hash access slower than the inside-out equivalent Hash::Util::refaddr. That's the difference that matters afaik, otherwise they do about the same amount of almost nothing.

Anno


In reply to Re^6: Autovivifying XS routine by Anno
in thread Autovivifying XS routine by Anno

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.