Skip to content

Commit

Permalink
remove mentions of Parcel/parcel
Browse files Browse the repository at this point in the history
TimToady committed Oct 16, 2015
1 parent 70209e8 commit eb42709
Showing 11 changed files with 126 additions and 159 deletions.
83 changes: 38 additions & 45 deletions S02-bits.pod
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ Synopsis 2: Bits and Pieces

Created: 10 Aug 2004

Last Modified: 13 May 2015
Version: 295
Last Modified: 16 Oct 2015
Version: 296

This document summarizes Apocalypse 2, which covers small-scale lexical
items and typological issues. (These Synopses also contain updates to
@@ -2147,20 +2147,19 @@ something like:

the syntactic list is translated (at compile time, in this case) into a
C<Capture> object with three positionals and one named argument in
preparation for binding. More generally, a parcel is transmuted to a
preparation for binding. More generally, a list is transmuted to a
capture any time it is bound to a complete signature.

You may force immediate conversion to a C<Capture> object by prefixing the
parcel composer with a backslash:
list with a backslash:

$args = \(1,2,3,:mice<blind>)

Individual arguments in a parcel or capture composer are parsed as ordinary
Individual arguments in an argument list (or capture composer) are parsed as ordinary
expressions, and any functions mentioned are called immediately, with each
function's results placed as an argument (often a subparcel, if the function
returns multiple values) within the outer parcel (or capture). Whether any
function's results placed as an argument within the outer argument list. Whether any
given argument is flattened will depend on its eventual binding, and in
general cannot be known at parcel/capture composition time.
general cannot be known at composition time.

We use "argument" here to mean anything that would be taken as a single
argument if bound to a positional or named parameter:
@@ -2171,15 +2170,15 @@ argument if bound to a positional or named parameter:
rhyme((1,2),(3,:mice<blind>)) # rhyme has 2 arguments
rhyme((1,2,3,:mice<blind>)) # rhyme has 1 argument

In these examples, the first argument to the function is a parcel in all but
In these examples, the first argument to the function is a list in all but
the first case, where it is simply the literal integer 1. An argument is
either of:

=over

=item *

A parcel that groups together a sublist, or
A parenthesized list that groups together a sublist, or

=item *

@@ -2188,20 +2187,20 @@ Any other object that can function as a single argument.
=back

Looking at it the other way, all arguments that don't actually need to be
wrapped up in a parcel are considered degenerate parcels in their own right
wrapped up in a list are considered degenerate lists in their own right
when it comes to binding. Note that a capture is not considered a kind of
parcel, so does not flatten in flat context.
list, so does not flatten in flat context.

=head2 Parcels, parameters, and Captures
=head2 Lists, parameters, and Captures

When a C<Parcel> is bound to a parameter, the behavior depends on whether
When an argument is bound to a parameter, the behavior depends on whether
the parameter is "flattening" or "argumentative". Positional parameters and
slice parameters are argumentative and call C<.getarg> on the internal
iterator and just return the next syntactic argument (parcel or other
object) without flattening. (A slice differs from an ordinary positional
slice parameters are argumentative
and just return the next syntactic argument
without flattening. (A slice differs from an ordinary positional
parameter in being "slurpy", that is, it is intended to fetch multiple
values from the variadic region of the surrounding capture. Slurpy contexts
come in both flattening (C<*> parameters) and slicing (C<**> parameters)
come in flattening (C<*> parameters), slicing (C<**> parameters), and one-arg (C<+> parameters)
forms.)

The fact that a parameter is being bound implies that there is an outer
@@ -2210,14 +2209,14 @@ C<.get> and a C<.getarg> method to tell the iterator what context to bind
in. For positional/slice parameters, the C<.getarg> method returns the
entire next argument from the iterator. It returns other objects unchanged.
In contrast, flat parameters call C<.get> on the capture's iterator, which
flattens any subparcels before pulling out the next item. In either case,
no bare parcel object is seen as a normal bound argument. (There is a way
to bind the underlying parcel using backslash, however. This is how
internal routines can deal with parcels as real objects.)
flattens any sublists before pulling out the next item. In either case,
no bare list object is seen as a normal bound argument. (There is a way
to bind the underlying list using backslash, however. This is how
internal routines can deal with lists as real objects.)

In contrast to parameter binding, if a C<List> is bound to an entire
signature (typically as part of a function or method call), it will be
transformed first into a capture object, which is much like a parcel but has
transformed first into a capture object, which is much like a list but has
its arguments divvied up into positional and named subsets for faster
binding. (Usually this transformation happens at compile time.) If the
first positional is followed by a colon instead of a comma, it is marked as
@@ -2241,7 +2240,7 @@ eventual value may well be unknown. All we know is that we have the promise
to make the bits of it immutable as they become known.

C<Capture> objects may contain multiple unresolved iterators such as feeds
or parcels or lists of parcels. How these are resolved depends on what they
or lazy lists. How these are resolved depends on what they
are eventually bound to. Some bindings are sensitive to multiple dimensions
while others are not. Binding to a list of lists is often known as
"slicing", because it's commonly used to index "slices" of a potentially
@@ -2262,7 +2261,7 @@ parentheses. The special syntax form C<$()> translates into C<$( $/.made //
Str($/) )> to operate on the current match object; similarly C<@()> and
C<%()> can extract positional and named submatches.

C<Parcel> and C<Capture> objects fill the ecological niche of references in
C<Capture> objects fill the ecological niche of references in
Perl 6. You can think of them as "fat" references, that is, references that
can capture not only the current identity of a single object, but also the
relative identities of several related objects. Conversely, you can think
@@ -2387,27 +2386,21 @@ applied (primed) by using the C<.assuming> method:

&foo.assuming(1,2,3,:mice<blind>)

=head2 Multidimensional slices and parcels
=head2 Multidimensional slices and lists

Slicing syntax is covered in S09. A multidimensional slice will be done
with semicolons between individual slice sublists. The semicolons imply one
extra level of tree-ness, where the top list is of type C<LoL> and sublists
are C<Lists>s (or non-iterable items that can function as single-item
parcels). So when you say
extra level of tree-ness. So when you say

@matrix[1..*; 0]

really means

@matrix[LoL.new( (1..*), 0 )]
@matrix[List.new( (1..*), 0 )]

or more briefly,
Each such slice sub-list is evaluated lazily.

@matrix[lol (1..*), 0]

Each such slice sub-parcel is evaluated lazily.

Just as parens and brackets can be used to compose parcels and arrays, if
Just as parens and brackets can be used to compose lists and arrays, if
you put any semicolons into either form, it becomes a multi-dimensional
composer:

@@ -3522,7 +3515,7 @@ is equivalent to:
$a = ('a', 'b');

which assigns a C<List> to the variable. On the other hand, if you
backslash the parcel:
backslash the list:

$a = \<a b>;

@@ -3535,7 +3528,7 @@ into a separate structure, in contrast to a C<List>, which keeps
everything in its original list).

Binding is different from assignment. If bound to a signature, the C<< <a
b> >> parcel will be promoted to a C<Capture> object, but if bound to a
b> >> list will be promoted to a C<Capture> object, but if bound to a
parameter, it will make the flattening/slicing decision based on the nature
of the individual parameter. That is, if you pass C<< <a b> >> as an
argument, it will bind as a single item to a positional or slice parameter,
@@ -3567,7 +3560,7 @@ clarity as well as correctness:

=head3 Empty List

Even though there is no comma in it, the empty parcel is represented by
Even though there is no comma in it, the empty list is represented by
C<()>. Normally, one could itemize this by prefixing a C<$> (as in C<$()>),
but that translates to the special syntax form C<$( $/.made // Str($/) )>.
Instead, one can C<().item>, or less legibly, introduce a space as in C<$(
@@ -4708,19 +4701,19 @@ There is a "C<list>" operator which imposes a list context on its arguments
even if C<list> itself occurs in item context.

To force explicit flattening, use the C<flat> contextualizer. This
recursively flattens all parcels into a 1-dimensional list. When bound to a
recursively flattens all lists into a 1-dimensional list. When bound to a
slurpy parameter, a capture flattens the rest of its positional arguments.

To reform a list so that sub-parcels turn into tree nodes, use the C<.tree>
To reform a list so that sub-lists turn into tree nodes, use the C<.tree>
method, which is essentially a level-sensitive C<map>, with one closure
provided for remapping the parcels at each level:
provided for remapping the lists at each level:

$p.tree # recursively set all levels to item
$p.tree(*) # same thing
$p.tree(*.item) # force level 1 parcels to item
$p.tree(*.item) # force level 1 lists to item
$p.tree(1) # same thing
$p.tree(*.item,*.list) # force level 1 parcels to item, level 2 to list
$p.tree(*.Array,*) # Turn all subparcels into item recursively
$p.tree(*.item,*.list) # force level 1 lists to item, level 2 to list
$p.tree(*.Array,*) # Turn all sublists into item recursively

When bound to a slice parameter (indicated with C<**>), a capture reforms
the rest of its positional arguments with one level of "treeness",
21 changes: 5 additions & 16 deletions S03-operators.pod
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ Synopsis 3: Operators

Created: 8 Mar 2004

Last Modified: 8 Apr 2015
Version: 287
Last Modified: 16 Oct 2015
Version: 288

=head1 Overview

@@ -700,7 +700,7 @@ argument.

C<< prefix:<||> >>, flatten object into semicolon list

|| $parcel
|| $list

Interpolates the elements of the C<List> (or any other ordered or iterable value)
into the current argument list as if they had been specified literally,
@@ -1937,7 +1937,7 @@ if they do match you may interleave unrelated sequences:

1,1,{ $^a + 1, $^b * 2 }...* # 1,1,2,2,3,4,4,8,5,16,6,32...

Note in this case that the any limit test is applied to the entire parcel
Note in this case that the any limit test is applied to the entire list
returned from the function, which contains two values.

A sequence generated from an explicit function places no type
@@ -2552,17 +2552,6 @@ contain no embedded C<List>, C<Seq> or C<Range> objects.

=item *

The C<lol> contextualizer

lol foo()

Forces the subsequent expression to be evaluated in list-of-lists
context. This is typically used to form a multidimensional slice.
A parcel potentially containing subparcels will be transformed into
a list of lists, specifically of type C<LoL>.

=item *

The C<hash> contextualizer

hash foo()
@@ -4621,7 +4610,7 @@ together, just as if you had written it out explicitly:
[<] 1, 3, 5; # 1 < 3 < 5

For list infix operators, flattening is not done on the input list, so
that multiple parcels may be passed in as comma-separated arguments:
that multiple lists may be passed in as comma-separated arguments:

[X~] (1,2), <a b>; # 1,2 X~ <a b>

27 changes: 12 additions & 15 deletions S04-control.pod
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ Synopsis 4: Blocks and Statements

Created: 19 Aug 2004

Last Modified: 19 Sep 2015
Version: 140
Last Modified: 16 Oct 2015
Version: 141

This document summarizes Apocalypse 4, which covers the block and
statement syntax of Perl.
@@ -324,7 +324,7 @@ and that is equivalent to:

(Only a single statement is allowed inside parens or brackets; otherwise
it will be interpreted as a LoL composer.
See L<S02/"Multidimensional slices and parcels">.)
See L<S02/"Multidimensional slices and lists">.)

=head2 The C<with> and C<without> statements

@@ -812,7 +812,7 @@ If you take multiple items in a comma list (since it is, after all, a list
operator), they will be wrapped up in a C<List> object for return as the
next argument. No additional context is applied by the C<take> operator,
since all context is lazy in Perl 6. The flattening or slicing of any such
returned parcel will be dependent on how the C<gather>'s return iterator is
returned list will be dependent on how the C<gather>'s return iterator is
iterated (with C<.get> vs C<.getarg>).

The value returned by the C<take> to the C<take>'s own context is that same
@@ -822,9 +822,9 @@ added to the list of values being gathered, which is returned by the
C<gather> as a lazy list (that is, an iterator, really), with each argument
element of that list corresponding to one C<take>.

Any parcels in the returned list are normally flattened when bound into flat
context. When bound into a lol context, however, the parcel objects become
real C<List> objects that keep their identity as discrete sublists. The
Any sublists in the returned list are normally flattened when bound into flat
context. When bound into a slice context, however, the sublist objects
keep their identity as discrete sublists. The
eventual binding context thus determines whether to throw away or keep the
groupings resulting from each individual C<take> call. Most list contexts
are flat rather than sliced, so the boundaries between individual C<take>
@@ -846,17 +846,17 @@ to keep track of what you last "took":
The C<take> function essentially has two contexts simultaneously, the
context in which the C<gather> is operating, and the context in which the
C<take> is operating. These need not be identical contexts, since they may
bind or coerce the resulting parcels differently:
bind or coerce the resulting lists differently:

my @y;
my @x = gather for 1..2 { # flat context for list of parcels
my @x = gather for 1..2 { # flat context for list of lists
my ($y) := \(take $_, $_ * 10); # binding forces item context
push @y, $y;
}
# @x contains 4 Ints: 1,10,2,20 flattened by list assignment to @x
# @y contains 2 Lists: $(1,10),$(2,20) sliced by binding to positional $y

Likewise, we can just remember the gather's result parcel by binding and
Likewise, we can just remember the gather's result list by binding and
later coercing it:

my ($c) := \(gather for 1..2 {
@@ -1589,10 +1589,7 @@ from that point.

For phasers such as C<KEEP> and C<POST> that are run when exiting a scope
normally, the return value (if any) from that scope is available as the
current topic within the phaser. (It is presented as a argument, that is,
either as parcel or an object that can stand alone in a list. In other
words, it's exactly what C<return> is sending to the outside world in raw
form, so that the phaser doesn't accidentally impose context prematurely.)
current topic within the phaser.

The topic of the block outside a phaser is still available as C<<
OUTER::<$_> >>. Whether the return value is modifiable may be a policy of
@@ -1773,7 +1770,7 @@ exception, though returning a defined value after catching an exception is
okay.

In the absence of error exception propagation, a successful exit is one that
returns a defined value or parcel. (A defined parcel may contain undefined
returns a defined value or list. (A defined list may contain undefined
values.) So any Perl 6 function can say

fail "message";
2 changes: 1 addition & 1 deletion S05-regex.pod
Original file line number Diff line number Diff line change
@@ -4395,7 +4395,7 @@ object is then passed as the invocant to the C<TOP> method (regex, token,
or rule) of C<MyGrammar>. The default rule name to call can be overridden with
the C<:rule> named argument of the C<parse> method. This is useful for unit testing
the rules of a grammar. As methods, rules can have arguments, so the C<:args> named
argument is used to pass such arguments as a parcel if necessary.
argument is used to pass such arguments as a list if necessary.

Grammar objects are considered immutable, so
every match returns a different match state, and multiple match states may
Loading
Oops, something went wrong.

0 comments on commit eb42709

Please sign in to comment.