What is the point of saying "I want a list context" if you don't actually want something from the list?...
The equivalent:
my $scalar = list function();doesn't make sense because there is no universal "list in scalar context" behavior.
I find these remarks puzzling. As I understand it, the standard "list in scalar context" behavior is "size of the list". Furthermore, any function whose return value changes depending on the context (e.g. by using wantarray), gives rise to situations in which this hypothetical list operator would be useful. The canonical example of this is m//. If I want to find out how many times m/(pattern)/g matched, I have to resort to mysterious-looking trickery:
or else pointless, Javaoid verbositudinositiness:my $n = () = $string =~ m/(pattern)/g;
It seems to me more civilized to simply request m//'s list context behavior:my @useless = $string =~ m/(pattern)/g; my $n = @useless;
my $n = list $string =~ m/(pattern)/g;
the lowliest monk
In reply to Re^2: What's most efficient way to get list context? (honest)
by tlm
in thread What's most efficient way to get list context?
by tlm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |