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

Re: mauve::reftype()

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
September 9, 2010 09:49
Subject:
Re: mauve::reftype()
Message ID:
20100909164937.GB13876@klangraum.plasmasturm.org
* demerphq <demerphq@gmail.com> [2010-08-30 11:40]:
> Thus we could easily have extra flags in sv_reftype_len() and
> add new functions for both more and less fine grained
> responses.
>
> mauve::dereftype($foo)
>
> which would return based on how you dereference, and also maybe a

Actually, it seems to me `reftype` is being made to do two jobs
at once: it tells you what is at the other end of a reference,
and if that happens to be a scalar, it *also* tells you what
*kind* of scalar. It think this double duty should be split: one
`reftype`, which tells you SCALAR for any kind of scalar, and one
`scalartype` which tells you what kind of scalar, for which

    is( scalartype( \%_ ), !1 );

Note that while I am not entirely sure right now, `scalartype`
might have to take a reference to a scalar rather than a scalar,
because

    is( scalartype( substr $_, 0 ), 'LVALUE' );
    my $x = \substr $_, 0;
    is( scalartype( $$x ), 'LVALUE' );

should both hold, and I’m not sure the latter would. Whereas if
`scalartype` required a reference, no such problems would crop
up.

> mauve::exacttype()
>
> which would return stuff like "IV" for \123.

That feels like an attractive nuisance rather than something
truly useful… I think that level of detail should be left for
some kind of Devel:: to provide, and whoever needs it can get
it there.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About