Fri, May 06, 2005 at 06:35:45PM +0200, Juerd wrote:
: Which things can receive?
:
: If I recall things correctly, we already have these:
:
: sub # slurpy list
: arrary
: hash
:
: Would it make sense to add, for example,
:
: filehandle # write
:
: It may not, as it's not reversible like the others are: a filehandle in
: list context doesn't slurp. It's probably better to let this be done
: only with io().
That's one of the reasons io() is so Huffmanly short, I imagine.
: When piping to a scalar, I assume its reftype will determine what will
: happen. But what if the scalar is undef? Is it then assumed to want to
: behave like an array?
How does it autovivify, in other words? Maybe it autovivifies to
an iterator:
do_stuff() my $iter;
for =$iter {}
If someone wants to use an array, I don't see why they wouldn't just use @.
: When is the pointy side evaluated?
Whenever it asks for more data, and more data is available.
: How do you pipe to an array returned by a sub? @ foo()?
foo()[]
That'd work for
$foo[]
as well, presumably, and autovivify an array in $foo.
We probably ought to consider the parallel aspects of piping to a hash,
since there's no requirement that a hash be built in order. With the
recent change to allow multiple input pipes, the pipes could probably
be run in parallel:
my %result <== [<==] @pairgenerators;
my %result{()} = 1 <== [<==] @keygenerators;
Actually that wouldn't work, since %result <== @a <== @b implies that
@b passes through @a on its way to %result. Maybe I mean something
more like:
my %result <== @pairgenerators;
my %result{()} = 1 <== @keygenerators
But actually, %result <== @a <== @b doesn't imply passage through
@a unless <== is right associative like assignment. If it's left
associative, it means (%result <== @a) <== @b, which can probably be
parallelized, just like @b %result <== @a, and any other constructs
that can be borrowed from the B*f* class of languages.
I suppose is left associative, which means that
@a foo() %result
does go through foo(). But that probably means
%result <== foo() <== @a
really wants to be right associative, which means we can't reduce with
it. However, we just got through saying that ; is basically equivalent
to < But ; could be construed as left associative, so maybe we can
say it like this:
my %result <== [;] @pairgenerators;
my %result{()} = 1 <== [;] @keygenerators;
Interestingly, reduction with [;] works at the top level and can't
be confused with statement-final semicolon.
So if we want to parallize input pipes, we just bind to Lazy *array
and arrange to read whichever lazy list has something for us. Probably
need some kind of internal support for that. Maybe any(@array).shift can
do it.
: topic, but I just thought of this again: is whitespace allowed or
: disallowed between sigil and name?
Disallowed.
Larry