develooper Front page | perl.perl5.porters | Postings from April 2008

Re: prototypes, parsing and optrees

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
April 30, 2008 00:29
Subject:
Re: prototypes, parsing and optrees
Message ID:
b77c1dce0804300029t67355ffaj46eca5efe6216ec6@mail.gmail.com
2008/4/29 Nicholas Clark <nick@ccl4.org>:
>  $ diff -u <(perl -MO=Concise -e 'sub foo (\@); foo @ARGV') <(perl -MO=Concise -e 'sub foo; foo \@ARGV')
>  -e syntax OK
>  -e syntax OK
>  --- /dev/fd/63  2008-04-29 18:34:05.000000000 +0100
>  +++ /dev/fd/62  2008-04-29 18:34:05.000000000 +0100
>  @@ -4,7 +4,7 @@
>   9     <1> entersub[t2] vKS/TARG,1 ->a
>   -        <1> ex-list K ->9
>   3           <0> pushmark s ->4
>  -7           <1> refgen KM/1 ->8
>  +7           <1> refgen lKM/1 ->8
>   -              <1> ex-list lKRM ->7
>   4                 <0> pushmark sRM ->5
>   6                 <1> rv2av[t1] lKRM/1 ->7
>
>  The version without the prototype has an extra l flag on the refgen. (If I've
>  understood the documentation of B::Concise correctly, that means that it knows
>  that it's in list context).
>
>  How come the version with the \@ prototype isn't able to work out that it is
>  in list context?

That doesn't matter. There's only one argument. The only purpose of the
l flag on refgen is to allow things like

    \(@foo, @bar)

to return two array refs, and not flatten the (@foo, @bar) list.

>  (and am I right in thinking that prototypes only influence the parser - once
>  run time is reached, nothing is the wiser?)

Yes.

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