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

Re: prototypes, parsing and optrees

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
April 29, 2008 11:38
Subject:
Re: prototypes, parsing and optrees
Message ID:
20080429183038.GQ19658@klangraum.plasmasturm.org
* Nicholas Clark <nick@ccl4.org> [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.

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