Re: Passing arguments

2002-09-19 Thread Aaron Sherman
On Sat, 2002-09-14 at 04:16, Luke Palmer wrote: > When a bare closure is defined, it behaves the same as a signatureless > sub. That is, it topicalizes the first argument, and hands them all over > in @_. So your "topic passing" is just, well, passing the topic, like > any ol' argument. Ok,

RE: Passing arguments

2002-09-19 Thread Brent Dax
Aaron Sherman: # topicalize: To default to C<$_> in a prototype (thus # acquiring the caller's current topic). Well, to topicalize a region of code is actually to specify a different topic, that is, a different value for $_. For example: $foo = new X; $bar = new Y;

RE: Passing arguments

2002-09-20 Thread Larry Wall
On Thu, 19 Sep 2002, Brent Dax wrote: : Aaron Sherman: : # topicalize: To default to C<$_> in a prototype (thus : # acquiring the caller's current topic). : : Well, to topicalize a region of code is actually to specify a different : topic, that is, a different value for $_. For example: : :

RE: Passing arguments

2002-09-20 Thread Brent Dax
Larry Wall: # That binds the dynamically surrounding $_ to $x as an # out-of-band parameter. Can also bind to $_ to make it the # current topic. The problem I have with that is this: sub for_trace(*@array, &block) { loop($_=0; $_ < @array; $_++) {

RE: Passing arguments

2002-09-20 Thread Aaron Sherman
On Fri, 2002-09-20 at 10:36, Larry Wall wrote: > On Thu, 19 Sep 2002, Brent Dax wrote: > : (An aside: it strikes me that you could use C as a scoped lexical > : alias, i.e. > : given $bar -> $foo { > : print $foo; > : } > Sure, though it also aliases to $_. > Does that mean

RE: Passing arguments

2002-09-20 Thread Larry Wall
On Fri, 20 Sep 2002, Brent Dax wrote: : Larry Wall: : # That binds the dynamically surrounding $_ to $x as an : # out-of-band parameter. Can also bind to $_ to make it the : # current topic. : : The problem I have with that is this: : : sub for_trace(*@array, &block) { : l

RE: Passing arguments

2002-09-20 Thread Larry Wall
On 20 Sep 2002, Aaron Sherman wrote: : On Fri, 2002-09-20 at 10:36, Larry Wall wrote: : > On Thu, 19 Sep 2002, Brent Dax wrote: : : > : (An aside: it strikes me that you could use C as a scoped lexical : > : alias, i.e. : > : given $bar -> $foo { : > : print $foo; : > : } : : > Sur

RE: Passing arguments

2002-09-20 Thread Larry Wall
On 20 Sep 2002, Aaron Sherman wrote: : I assumed that's what C was. It does have the disadvantage of : looking like variable assignment, though. BTW, latest leaning is toward = rather than //= for parameter defaults, since it can, in fact, be undef if the parameter is supplied, while //= seems to

RE: Passing arguments

2002-09-20 Thread Sean O'Rourke
On Fri, 20 Sep 2002, Larry Wall wrote: > The current thinking as of Zurich is that the "given" passes in > separate from the ordinary parameters: > > sub ($a,$b,$c) is given($x) {...} > > That binds the dynamically surrounding $_ to $x as an out-of-band > parameter. Can also bind to $_ to mak

Re: Passing arguments

2002-09-20 Thread Angel Faus
Larry said: > BTW, latest leaning is toward = rather than //= for parameter > defaults, ... Horray! Sorry. Couldn't resist. :-) -angel "Simple men are happy with simple presents"

RE: Passing arguments

2002-09-20 Thread Larry Wall
On Fri, 20 Sep 2002, Sean O'Rourke wrote: : On Fri, 20 Sep 2002, Larry Wall wrote: : > The current thinking as of Zurich is that the "given" passes in : > separate from the ordinary parameters: : > : > sub ($a,$b,$c) is given($x) {...} : > : > That binds the dynamically surrounding $_ to $x as

Re: Passing arguments

2002-09-20 Thread Adam D. Lopresto
Personally, I like the looks of sub foo($a, $b is given) { ... } > Does this mean that we allow/encourage uses of $_ other than as a default > for an optional argument? I think it would be less confusing and > error-prone to associate the underscore-aliasing with the parameter $_ > wil

Re: Passing arguments

2002-09-21 Thread Smylers
Larry Wall wrote: > On 20 Sep 2002, Aaron Sherman wrote: > > : Does that mean that I can't > : > : for $x -> $_ { > : for $y -> $z { > : print "$_, $z\n"; > : } > : } > : > : And expect to get different values? > > That's correct. N

Re: Passing arguments

2002-09-21 Thread Paul Johnson
On Sat, Sep 21, 2002 at 10:05:50AM -, Smylers wrote: > Larry Wall wrote: > > > On 20 Sep 2002, Aaron Sherman wrote: > > > > : Does that mean that I can't > > : > > : for $x -> $_ { > > : for $y -> $z { > > : print "$_, $z\n"; > > : } > > :

Re: Passing arguments

2002-09-21 Thread Luke Palmer
On 21 Sep 2002, Smylers wrote: > Larry Wall wrote: > > > On 20 Sep 2002, Aaron Sherman wrote: > > > > : Does that mean that I can't > > : > > : for $x -> $_ { > > : for $y -> $z { > > : print "$_, $z\n"; > > : } > > : } > > : > > : And exp

Re: Passing arguments

2002-09-29 Thread Smylers
Paul Johnson wrote: > On Sat, Sep 21, 2002 at 10:05:50AM -, Smylers wrote: > > > Many Perl programs use C<$_> to mean > > 'the current line'. 'A2' gives the Perl 6 syntax for this as: > > > >while $STDIN { > > > > Maybe somewhere in the middle of > > it, it's necessary to have a C loo

Re: Passing arguments

2002-09-30 Thread Paul Johnson
On Sun, Sep 29, 2002 at 09:31:46PM -, Smylers wrote: > Consider this Perl 5: > > while (<>) > { > # ... > foreach my $fruit (qw) > { > # ... > } > } > > Inside the inner loop C<$_> still holds the current line. In the > equivalent Perl 6 syntax, insider the inne