Larry Wall a écrit :
| On Fri, Nov 11, 2005 at 08:42:44AM -0500, Joe Gottman wrote:
| : Do functions like map and grep, which in Perl5 return lists, return
| : Iterators in Perl6?
| 
| A list may contain iterators.  Lists don't eagerly flatten in Perl 6.
| 
| : Can an Iterator be passed to a function (like map and grep again)
| : that requires a list as an input?
| 
| Certainly.  You can pass as many iterators as you like.  The range object
| is your prototypical iterator, and you can say:
| 
|     @results = grep {...} 0..9, 20..29, 40..49;
| 
| The list that grep is returning can also function as an iterator, so
| @results isn't necessarily "all there" after the statement executes.
| 

How can Perl6 can consistently cope with side effects if it is not
specified when evaluation is lazy or strict? Is there a trait to say
that a function (here the grepping predicat) does not have
side-effect or is also really functional (so as to permit various
optimizations)?

Ate they  pragma to say, "from here every function that will be defined will 
by default functional" or "every parameter evaluation will be lazy":

  use fun;
  use lazy;

   sub foo {$a } { ...  } # functional and lazy

   sub notfunctional($a) isnot fun {...)  # can we unset a default attribute?

  no fun;  # use strict has another meaning btw.
  ...
  use fun, lazy; # also can we do use bundling?

More generally I am worried of the mix of lazy and strict behavior in
the presence of all sorts of side effects that would happen in a random
order depending of the parameter evaluation order.

btw, for strict functions, is the left to right evaluation of
parameters guaranteed?

| 
| Larry
| 

--
cognominal stef

Reply via email to