[Israel.pm] List of all contexts in Perl

Yuval Kogman nothingmuch at woobling.org
Sun May 30 09:09:00 PDT 2010

On 29 May 2010 23:16, Yossi Itzkovich <Yossi.Itzkovich at ecitele.com> wrote:

>  Hi,
> Where can I find a list of all possible contexts in Perl ?  In the past I
> thought there were only scalar and list, but I remember that there are more
> (such as Boolean).
> As others mentioned, Want contains a comprehensive list.

However, those aren't contexts per se. They are implied.

The context stack (which contains the loop and block portions of a
traditional stack) contains only void/list/scalar.

They are really more a case of introspective metaprogramming, and therefore
the definition is quite arbitrary.

The Want module inspects the return address of these stack frames, and then
inspects the optree at that point, to provide more information on what will
be done to the return value.

So, for instance:


inside foo() the return address will be the method resolution opcode and
then the entersub opcode to dispatch it, so by looking at that program
structure it is knows the return value from 'foo' will be used in a method

See Want.pm for more examples.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20100530/1691a482/attachment.htm 

More information about the Perl mailing list