in reply to wantarray documentation in 5.8.7

What is meant is that wantarray is meaningless if there is no calling context. Which is the case in a BEGIN, CHECK, INIT or END block, a DESTROY method, and the "top level of a file" when you're executing that file. Obviously, it has not much to do with the physical location of the code in a file (although the "top level" is often located at the top).

Of course, you could change it to "when there's no calling context", but then half a year down the road, someone will find that sentence confusing, and change to "top level of a file".

Replies are listed 'Best First'.
Re^2: wantarray documentation in 5.8.7
by polettix (Vicar) on Jul 25, 2005 at 13:39 UTC
    Of course, you could change it to "when there's no calling context", but then half a year down the road, someone will find that sentence confusing, and change to "top level of a file".
    Which will make it confusing for others. A no-op seems wrong to me in this case; maybe the better thing is to make an effort to definitely clarify this matter.

    What we really lack here is maybe a formal definition of context, and in particular of when you have a context and when you don't have it. I know that perldata has an entire section about context, but the definition results quite foggy IMHO, and resorts to wantarray to disambiguate. The classic dog-biting-its-own-tail problem. Moreover, I'm not in the position to propose an alternative, and this is quite frustrating.

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.
      Moreover, I'm not in the position to propose an alternative, and this is quite frustrating.
      Anyone is in the position to propose any alternative. It's done by sending a message to p5p, stating your case. Attaching a patch to your case strengthens it.