pugs-comm...@feather.perl6.nl wrote:
Author: lwall
Date: 2010-01-23 15:43:40 +0100 (Sat, 23 Jan 2010)
New Revision: 29582

@@ -1191,8 +1191,6 @@
     Block       Callable
-    Iterator    List
-    Seq         Iterable
     Range       Iterable
     Set         Associative[Bool]
     Bag         Associative[UInt]
@@ -1225,17 +1223,14 @@
 =head2 Mutable types
+ Iterator Perl list
+    Seq         Partially or completely reified list
     Scalar      Perl scalar
     Array       Perl array
     Hash        Perl hash
@@ -1298,6 +1293,8 @@
+C<Seq> is mutable insofar as it it generated
+lazily, but the portion of the list that is already reified is
+considered immutable.

I'm not sure that declaring "Seq" mutable is the best move here.

I believe that the definitive test for considering something immutable or mutable is in its semantics as observed by its consumers/readers.

If a Seq guarantees that multiple reads from it by anyone over time will see exactly the same result, then it is immutable. Or put in functional terms, for all Seq $s, if the result of "f($s)" is deterministic for every possible "f()", then $s is immutable.

I believe that the fact Seq is lazy is just an implementation detail and has no bearing on its immutable status as defined above. Sure, we may not know in advance what all the elements of Seq will be until it is fully reified, but once anyone tries to use those values once, any subsequent attempts by anyone to use those values will get the *same* values, which is the point of immutability.

So I strongly recommend to make "Seq" immutable again.

Anything can be made lazy if the implementer wants to, and also anything can be made mutable if Perl 6 permits access to the guts of that thing, such as to ask "what are this Seq's reified elements" or "swap out the Seq's generator code with this one", but allowing such suggests that all bets are off anyway.

-- Darren Duncan

Reply via email to