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

Re: prototypes, parsing and optrees

Thread Previous | Thread Next
Aristotle Pagaltzis
April 29, 2008 11:38
Re: prototypes, parsing and optrees
Message ID:
* Nicholas Clark <> [2008-04-29 19:40]:
> 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?

But is it in list context?

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

Well, except for the fact that a sub with a prototype can put
some of its arguments in scalar context, whereas one that has no
prototype will simply put all of its arguments in list context.
So it seems logical that the prototype-less sub would put the
`refgen` in list context since it puts *all* of its arguments in
list context.

What I am a little surprised about is that in the prototyped sub,
the `refgen` isn’t in scalar context *either*. OTOH, `refgen` is
unaffected by context anyway, and while taking a reference is not
a list context, it’s not really a scalar context either.

So that observation seems to be an interesting bit of trivia but
inconsequential to user-visible semantics.

Aristotle Pagaltzis // <>

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