in reply to Re^3: What's most efficient way to get list context? (honest)
in thread What's most efficient way to get list context?

You should note that your winner does not exhibit that behavior.

Well there are two issues here (and as tye already noted, they are only meaningful in unusual situations such as benchmarking): one is what to wrap around an expression to induce perl to evaluate it in list context, and the other one is what is the value that this whole ball of code will return. The "winner" in my original node happens to do more than simply return the list that was produced by the wrapped expression. I can imagine any number of "wrappers" that would succeed in inducing a list context in the evaluation of the wrapped expreesion, and yet return entirely disparate things. And this is kind of my point: it makes no sense to have to wrap extraneous code around an expression just to "tell" perl to evaluate it in list context.

the lowliest monk

  • Comment on Re^4: What's most efficient way to get list context? (honest)

Replies are listed 'Best First'.
Re^5: What's most efficient way to get list context? (honest)
by Roy Johnson (Monsignor) on Apr 15, 2005 at 14:56 UTC
    it makes no sense to have to wrap extraneous code around an expression just to "tell" perl to evaluate it in list context
    Assignment to an empty list is an easy and sensible way to apply list context to a function. It's no more extraneous than a list keyword; it's just more idiomatic.

    There's even a kind of symmetry: you can't assign a scalar to undef, so you have a scalar keyword; you can assign a list to (), so you don't need a list keyword.


    Caution: Contents may have been coded under pressure.