Qui, 2008-09-11 às 12:13 -0700, Larry Wall escreveu: > And I guess the fundamental underlying constraint is that a list cannot > be considered immutable unless its feeds can be considered immutable, > at least in some kind of idempotent sense. This conflicts with the > whole point of reactive programming, which is that you have to react > because don't know what's coming.
This is actually something I was talking in the IRC this week. The amount of polymorphism Perl 6 supports makes it quite impossible to detect if the feeds can be considered immutable or not (in terms of concept, I mean, runtime tips could allow optimizations). But one thing needs to be clear, "List" is immutable as a type, meaning that the API for List only allows you to read from it, not write to it, but it doesn't necessarily means that it is immutable as an instance, because the List might have a "live" backend. Since List is not a native type, the interpreter doesn't really have any control on what it does to provide its values, and that's what I mean by saying that we can't infer if the feeds can or cannot be considered immutables. > This seems like it's close to the fundamental difficulty we're trying > to solve here. And maybe the solution is much like the value/object > distinction, where lists get to *decide* for themselves where they > switch from easy eager immutable semantics to hard lazy reactive semantics. > And if we're pretty clear about the boundary between those, it > could work out much like the boundary between DFAable regexes and > side-effectful regexes as defined in S05. And maybe it's even the > same boundary in some theoretical sense. The problem is that this concept should apply to the entire chain, this means that it can only be considered easy if all the feeds on the chain are easy, and it is too easy for it to be considered hard... for instance, is a 'map' considered easy or hard? In the end, that means that most of the time "easy" feeds will be made dirty by hard feeds and all the chain will be made lazy, so we have little gain. In SMOP, I'm probably going to presume that everything needs to be lazy, then even: my @o = grep { /\d+/ } =$*IN; my @a = (1,2,(3,4,@o)); my @b = (1,2,(3,4,@a)); Will still allow @b to be seen in slice context, where you would see @a also in slice context, because @a was not eagerly evaluated when composing @b, and eventually @o might never be evaluated. I think this is consistent with the spec that says somewhere that the only operators that imply eager evaluation are the short-circuit boolean operators (besides the 'eager' operator, of course, and the use of lazy values in void context). Of course the spec only says that it should be lazy with the feed operators, but in SMOP I tend to think that all this evaluation will be lazy. daniel