develooper Front page | perl.perl5.porters | Postings from August 2010

Re: mauve::reftype()

Thread Previous | Thread Next
August 30, 2010 02:37
Re: mauve::reftype()
Message ID:
On 30 August 2010 11:07, Zsbán Ambrus <> wrote:
> On Mon, Aug 30, 2010 at 9:42 AM, Nicholas Clark <> wrote:
>> We weren't convinced that it was viable to change the behaviour of
>> well used Scalar::Util functions this late in the game.
> Meanwhile, if we want to introduce functions with changed semantics,
> could we finally have a reftype that does away with the
> REF/GLOB/LVALUE/whatever madness and just returns SCALAR for any
> scalar, independent of what value it has?  The precise invariant I'd
> like is that refaddr($x) remains constant when you assign to $$x but
> not to $x.

Actually its interesting you ask this. For various reasons I kinda
reworked sv_reftype() and while doing so observed it is somewhat
capricious about this. Take a look at the documentation in
for reftype(), which is generated from parsing the code in
sv_reftype(), to see all the "kinds" of types that we might report. I
tried to include sample code of either how to dereference the thing,
or code to create one, but some of them im not sure how to create.

Anyway, one of my patches basically replaces sv_reftype() with a new
subroutine sv_reftype_len(), which currently mimics the old interface
except for requiring a pointer to a STRLEN also be provided. Now, this
is a new routine, so the current 'ob' "boolean" could be changed to be
a flags field, and we can make sv_reftype_len() return either /more/
or /less/ specific responses as is seen as is appropriate. Code that
call sv_reftype() will get the old behaviour (i want to make it fatal
error to call sv_reftype() with ob=true /anyway/ as as long as its
possible to create stashes with nulls in them we need to keep track of
lengths). Thus we could easily have extra flags in sv_reftype_len()
and add new functions for both more and less fine grained responses.


which would return based on how you dereference, and also maybe a


which would return stuff like "IV" for \123.


perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About