Perl6-Doc
view release on metacpan or search on metacpan
share/Apocalypse/A06.pod view on Meta::CPAN
=head2 Future Plans
From here on out, the Apocalypses are probably going to be coming out
in priority order rather than sequential order. The next major one
will probably be Apocalypse 12, Objects, though it may take a while
since (like a lot of people in Silicon Valley) I'm in negative cash
flow at the moment, and need to figure out how to feed my family.
But we'll get it done eventually. Some Apocalypses might be written
by other people, and some of them hardly need to be written at all.
In fact, let's write Apocalypse 7 right now...
=head1 Apocalypse 7: Formats
Gone from the core. See Damian.
=head1 Appendix A: Rationale for pipe operators
As we pointed out in the text, the named form of passing a list has
the disadvantage that you have to know what the formal parameter's
name is. We could get around that by saying that a null name maps
to the slurp array. In other words, we could define a C<< => >>
unary operator that creates a null key:
stuff(@foo, =>(1,2,3))
We can at least lose the outer parens in this case:
stuff @foo, =>(1,2,3)
But darn it, we can't get rid of those pesky inner parens because of
the precedence of C<< => >> with respect to comma. So perhaps it's
time for a new operator with looser precedence than comma:
stuff @foo *: 1,2,3 # * to match * zone marker
stuff @foo +* 1,2,3 # put the * on the list side
stuff @foo *=> 1,2,3 # or combine with => above
stuff @foo ==> 1,2,3 # maybe just lengthen =>
stuff @foo <== 1,2,3 # except the dataflow is to the left
stuff @foo with 1,2,3 # could use a word
Whichever one we pick, it'd still probably want to construct a special
pair internally, because we have to be able to use it indirectly:
@args = (\@foo, '*@' => (1,2,3));
stuff *@args;
[Update: Instead of a "special pair", we now have Capture objects.]
But if we're going to have a special operator to switch explicitly to
the list part, it really needs to earn its keep, and do more work.
A special operator could also force scalar context on the left and
list context on the right. So with implied scalar context we could
omit the backslash above:
@args = (@foo with 1,2,3);
stuff *@args;
That's all well and good, and some language designers would stop
right there, if not sooner. But if we think about this in relation
to cascaded list operators, we'll see a different pattern emerging.
Here's a left-to-right variant on the Schwartzian Transform:
my @x := map {...} @input;
my @y := sort {...} with @x;
my @z := map {...} with @y;
When we think of data flowing left-to-right, it's more like a pipe
operator from a shell, except that we're naming our pipes C<@x>
and C<@y>. But it'd be nice not to have to name the temporary
array values. If we do have a pipe operator in Perl, it's not going
to be C<|>, for two reasons. First, C<|> is taken for junctions.
Second, piping is a big, low-precedence operation, and I want a big
fat operator that will show up to the eye. Of our candidate list
above, I think the big, fat arrows really stand out, and look like
directed pipes. So assuming we have the C<< ==> >> operator to go
with the C<< <== >>, we could write our ST like this:
@input ==>
map {...} ==>
sort {...} ==>
map {...} ==>
push my @z;
That argues that the scalar-to-list transition operator should be C<< <== >>:
my @x := map {...} @input;
my @y := sort {...} <== @x;
my @z := map {...} <== @y;
And that means this should maybe dwim:
@args = (@foo <== 1,2,3);
stuff *@args;
Hmm.
That does imply that C<< <== >> is (at least in this case) a data
composition operator, unlike the C<< ==> >> operator which merely sends
the output of one function to the next. Maybe that's not a problem.
But people might see:
@x <== 1,2,3
and expect it does assignment when it in fact doesn't. Internally it
would really do something more like appending a named argument:
@x, '*@' => (1,2,3)
or however we decide to mark the beginning of the "real" list within
a larger list.
But I do rather like the looks of:
push @foo <== 1,2,3;
not to mention the symmetrical:
1,2,3 ==>
push @foo;
( run in 0.568 second using v1.01-cache-2.11-cpan-b16cb0d3907 )