Re: [svn:perl6-synopsis] r13543 - doc/trunk/design/syn

2007-01-29 Thread Gaal Yahas
On Mon, Jan 29, 2007 at 10:39:27AM -0800, [EMAIL PROTECTED] wrote:
 +Because Cgather evaluates its block or statement in void context,
 +this typically causes the Ctake statement to be evaluated in void
 +context.  However, a Ctake statement that is not in void context
 +gathers its arguments Ien passant and also returns them unchanged.
 +This makes it easy to keep track of what you last took:
 +
 +my @uniq = gather for @list {
 +state $previous = take $_;
 +next if $_ === $previous;
 +$previous = take $_;
 +}

What does it mean for take to be evaluated in void context?

What are the gathered values here?

   take 1, 2;  # easy. flattened 1 and then 2, right?
   @x = take 1, 2; # same thing?
   $x = take 1, 2; # same thing? [1, 2]?

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/


Re: [svn:perl6-synopsis] r13543 - doc/trunk/design/syn

2007-01-29 Thread Gaal Yahas
On Mon, Jan 29, 2007 at 10:01:08PM +0200, Gaal Yahas wrote:
  +Because Cgather evaluates its block or statement in void context,
  +this typically causes the Ctake statement to be evaluated in void
  +context.  However, a Ctake statement that is not in void context
  +gathers its arguments Ien passant and also returns them unchanged.
  +This makes it easy to keep track of what you last took:
  +
  +my @uniq = gather for @list {
  +state $previous = take $_;
  +next if $_ === $previous;
  +$previous = take $_;
  +}
 
 What does it mean for take to be evaluated in void context?
 
 What are the gathered values here?
 
take 1, 2;  # easy. flattened 1 and then 2, right?
@x = take 1, 2; # same thing?
$x = take 1, 2; # same thing? [1, 2]?

In fact, $x = take 5;# if this were Perl 5, I might expect
 # either 1 or [1] here!

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/


Re: [svn:perl6-synopsis] r13543 - doc/trunk/design/syn

2007-01-29 Thread Gaal Yahas
On Mon, Jan 29, 2007 at 10:08:34PM +0200, Gaal Yahas wrote:
 On Mon, Jan 29, 2007 at 10:01:08PM +0200, Gaal Yahas wrote:
   +Because Cgather evaluates its block or statement in void context,
   +this typically causes the Ctake statement to be evaluated in void
   +context.  However, a Ctake statement that is not in void context
   +gathers its arguments Ien passant and also returns them unchanged.
   +This makes it easy to keep track of what you last took:
   +
   +my @uniq = gather for @list {
   +state $previous = take $_;
   +next if $_ === $previous;
   +$previous = take $_;
   +}
  
  What does it mean for take to be evaluated in void context?
  
  What are the gathered values here?
  
 take 1, 2;  # easy. flattened 1 and then 2, right?
 @x = take 1, 2; # same thing?
 $x = take 1, 2; # same thing? [1, 2]?
 
 In fact, $x = take 5;# if this were Perl 5, I might expect
  # either 1 or [1] here!

Ugh, sorry, I meant either 1 or [5].

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/