Re: Subroutines: Extend subroutine contexts to include name parameters and lazy arguments

[email protected] (Johan Vromans) Fri, 18 Aug 2000 13:53:15 +0200 (CEST)
Newsgroups perl.perl6.language.subs
Message-ID <[email protected]>
> If the C<?> modifier is used for a particular parameter, that parameter
> is lazily evaluated. This means that it is only evaluated when the
> corresponding named parameter (see below) -- or the corresponding element
> of @_ -- is accessed in some way. Passing the parameter to another
> subroutine or returning it as an lvalue does not count as an access.

Can this be used to implement a Jensen device:

  sub work($i,?$j) {
    for $i ( 1..10 ) {
	print "$i: $j\n";
    }
  }

  my $foo;
  work($foo, $foo*$foo);		# prints 1 4 9 16 ...

-- Johan