Created
January 25, 2010 19:13
-
-
Save pmichaud/286129 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"List": | |
($a, @b, 1..1000, $c).map( { ... } ); | |
We need the lazy interpolating characteristics of list | |
context, but we don't want to be preserving every value | |
(e.g., the 1..1000) that is processed. Also, the elements | |
that are processed by .map are the original containers. | |
A "List" (but not the Parcel that produced it) is mutable | |
because we consume the values as we iterate over the list. | |
"Array": | |
my @x = ($a, @b, 1..1000, $c); | |
my $y = [$a, @b, 1..1000, $c]; | |
We again have interpolation in list context, but the | |
values produced from iterating the List/Parcel | |
are remembered in the reified portion of the Array. | |
Also, the elements in the Array are "eager" "copies" of | |
the rhs values from the List/Parcel, as opposed to | |
binding to any containers directly, thus after | |
the above assignment any changes to $a, @b, or $c | |
aren't reflected in @x. | |
"Seq": | |
my $z = ($a, @b, 1..1000, $c); | |
An immutable form of Array -- values produced from | |
iterating the List/Parcel are remembered in the reified | |
portion of the Array, and are "eager" "copies", but | |
neither the Seq nor its elements can act as lvalues. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment