Re: A suggestion for a new closure trait.

2006-08-29 Thread Sage La Torra
On 8/30/06, Jonathan Lang <[EMAIL PROTECTED]> wrote: Joe Gottman wrote: > Since a FIRST block gets called at loop initialization time, it seems to me > that it would be useful to have a block closure trait, RESUME, that gets > called at the beginning of every loop iteration except the first. Thu

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Carl Mäsak
Damian (>), Ruud (>>), Damian (>>>), Carl (): > >> But it can hardly be blamed for clarity. > > > > That's a little unfair. > > "can hardly be blamed" -> "can easily be praised" Apologies to Carl if I misinterpreted. I read it as: "can hardly be blamed for (having) clarity" ;-) No,

Re: A suggestion for a new closure trait.

2006-08-29 Thread Jonathan Lang
Joe Gottman wrote: Since a FIRST block gets called at loop initialization time, it seems to me that it would be useful to have a block closure trait, RESUME, that gets called at the beginning of every loop iteration except the first. Thus, at the beginning of each loop iteration either FIRST or R

Questions about statement modifiers

2006-08-29 Thread Agent Zhang
Hi, there~ I think S04 says too little about statement modifiers. Please comment on the following code samples. Are they valid Perl 6? do { say } for 1..3; { say } for 1..3; -> $i { say $i } for 1..3; And how about similar variations for other statement modifiers, such as while, giv

Re: could 'given' blocks have a return value?

2006-08-29 Thread Agent Zhang
On 8/30/06, Mark Stosberg <[EMAIL PROTECTED]> wrote: Sometimes I use 'given' blocks to set a value. To save repeating myself on the right hand side of the given block, I found I kept want to do this: my $foo = given { } According to S04, given {} is at statement level, so you can't use it di

Re: could 'given' blocks have a return value?

2006-08-29 Thread Jonathan Lang
Mark Stosberg wrote: Sometimes I use 'given' blocks to set a value. To save repeating myself on the right hand side of the given block, I found I kept want to do this: my $foo = given { } ...and have whatever value that was returned from when {} or default {} populate $foo. Isn't it still th

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Damian Conway
for @array -> $index, $value { say "Element $_ is called $value" } But I don't understand how the "$index, $value" pair gets its values; is @array somehow turned into a hash with the index as the key? With @array -> $index, $value {}, is $_ an alias of $index? No. There's no

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Dr.Ruud
"Damian Conway" schreef: > Ruud: >> Damian: >>> Carl: But it can hardly be blamed for clarity. >>> >>> That's a little unfair. >> >> "can hardly be blamed" -> "can easily be praised" > > Apologies to Carl if I misinterpreted. I read it as: > "can hardly be blamed for (having) clarity" >

could 'given' blocks have a return value?

2006-08-29 Thread Mark Stosberg
Sometimes I use 'given' blocks to set a value. To save repeating myself on the right hand side of the given block, I found I kept want to do this: my $foo = given { } ...and have whatever value that was returned from when {} or default {} populate $foo. It turns out pugs already allow this, thr

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Damian Conway
>> But it can hardly be blamed for clarity. > > That's a little unfair. "can hardly be blamed" -> "can easily be praised" Apologies to Carl if I misinterpreted. I read it as: "can hardly be blamed for (having) clarity" ;-) Damian

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Dr.Ruud
Damian Conway schreef: > [attribution repaired] Carl: >> But it can hardly be blamed for clarity. > > That's a little unfair. "can hardly be blamed" -> "can easily be praised" -- Affijn, Ruud "Gewoon is een tijger."

Re: named arguments: What's the signature?

2006-08-29 Thread Mark Stosberg
Trey Harris wrote: > > > Slurpy parameters follow any required or optional parameters. They are > marked by a C<*> before the parameter: > > sub duplicate($n, *%flag, [EMAIL PROTECTED]) {...} > > Named arguments are bound to the slurpy hash (C<*%flag> > in the above example). Such

A suggestion for a new closure trait.

2006-08-29 Thread Joe Gottman
Since a FIRST block gets called at loop initialization time, it seems to me that it would be useful to have a block closure trait, RESUME, that gets called at the beginning of every loop iteration except the first. Thus, at the beginning of each loop iteration either FIRST or RESUME but not both wo

Re: named arguments: What's the signature?

2006-08-29 Thread Stuart Cook
On 8/30/06, Mark Stosberg <[EMAIL PROTECTED]> wrote: Regarding The S06 description of named arguments: http://feather.perl6.nl/syn/S06.html#Named_arguments What I find missing here is documentation of the signature to use if you want to declare "I accept an arbitrary number of named arguments".

Re: named arguments: What's the signature?

2006-08-29 Thread Trey Harris
In a message dated Tue, 29 Aug 2006, Mark Stosberg writes: Regarding The S06 description of named arguments: http://feather.perl6.nl/syn/S06.html#Named_arguments What I find missing here is documentation of the signature to use if you want to declare "I accept an arbitrary number of named argu

named arguments: What's the signature?

2006-08-29 Thread Mark Stosberg
Regarding The S06 description of named arguments: http://feather.perl6.nl/syn/S06.html#Named_arguments What I find missing here is documentation of the signature to use if you want to declare "I accept an arbitrary number of named arguments". (Like the param() methods common in Perl5 do). Maybe

Perilous placeholder parameters

2006-08-29 Thread Stuart Cook
On 8/30/06, Damian Conway <[EMAIL PROTECTED]> wrote: That's a little unfair. Choose good names and it's perfectly clear: map { "Element $^array_index is called $^array_value" } <== @array.kv; As an aside, though, doesn't that particular solution now implicitly rely on the fact that ('inde

return Types: what are the enforcement details?

2006-08-29 Thread Mark Stosberg
I'm interested in helping to write some tests for "return types", but I'd like some clarifications about them first. Are they just "declarations" that help Perl optimize stuff, or they actually contracts? As this little script shows, both "inner" and "of" are valid syntax now with pugs, but neithe

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Damian Conway
pugs> map { "Element $^a is called $^b" }: @array.kv; ("Element 0 is called london", "Element 1 is called bridge", "Element 2 is called is", "Element 3 is called falling", "Element 4 is called down") But it can hardly be blamed for clarity. That's a little unfair. Choose good names and it's per

Fwd: Classes / roles as sets / subsets

2006-08-29 Thread Jonathan Lang
I accidently sent this directly to Richard. Sorry about that, folks... -- Forwarded message -- From: Jonathan Lang <[EMAIL PROTECTED]> Date: Aug 29, 2006 1:24 PM Subject: Re: Classes / roles as sets / subsets To: Richard Hainsworth <[EMAIL PROTECTED]> Richard Hainsworth wrote:

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Jonathan Scott Duff
Having read this thread, I tend to think you're insane for bringing it up again :-) That said, I'll entertain the discussion for a bit ... On Tue, Aug 29, 2006 at 08:33:20AM +0200, Carl Mäsak wrote: > Questions: > > - Is the itch big enough for this? The more I look at the first piece > of cod

Re: Classes / roles as sets / subsets

2006-08-29 Thread Mark J. Reed
On 8/29/06, Daniel Hulme <[EMAIL PROTECTED]> wrote: Perl up to 5 may be executable line noise, but I can see Perl 6 being the closest thing yet to executable maths, and I love it. Funny, I could have sworn APL was the closest thing yet to executable maths. ( Hey, wait a minute, I'm American;

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Dr.Ruud
Carl Mäsak schreef: > I suppose doing a map or a grep over @array.kv is possible: > > pugs> my @array = > ("london", "bridge", "is", "falling", "down") > > pugs> map { "Element $^a is called $^b" }: @array.kv; > ("Element 0 is called london", > "Element 1 is called bridge", > "Element 2 is call

Re: Classes / roles as sets / subsets

2006-08-29 Thread Daniel Hulme
> See diagram case 2 (Class A and Class B intersect): > & B are built from a role that represents their intersection ( Class > A U Class B), and then code is added in the definitions of the It may be just me being confused, but the symbol that looks like a U (U+222a) is usually union; intersect

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Carl Mäsak
Mark (>), Carl (>>): > Hey do you know what would be cool in perl 6 > A special variable for when you do a for (@array) style loop > it would always have the index of the array > > Discussed on #perl6: it's already quite easy in Perl 6 to loop with an > explicit index: > > my @array = ; > for

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Dr.Ruud
"Carl Mäsak" schreef: > Ruud: >> Carl: >>> But maybe a variable that implicitly carries along the loop index >>> would be even snazzier? >>> >>> for @array -> $val { >>> say "$.\t$val"; >>> } >> >> Or give the block a name (label), and have an index (or several >> indexes, like some that are res

Classes / roles as sets / subsets

2006-08-29 Thread Richard Hainsworth
Originally this posting was written in response to the 'ref' spec thread. I included char diagrams that got screwed up, so I made a png diagram instead (attached) and I re-edited the posting to refer to attached diagram, and then added some more comments. Hope everyone can 'see' the png. I fi

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Mark A. Biggar
Carl Mäsak wrote: Hey do you know what would be cool in perl 6 A special variable for when you do a for (@array) style loop it would always have the index of the array Discussed on #perl6: it's already quite easy in Perl 6 to loop with an explicit index: my @array = ; for @array.kv -> $i, $v

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Carl Mäsak
Ruud (>), Carl (>>): > But maybe a variable that implicitly carries along the loop index > would be even snazzier? > > for @array -> $val { > say "$.\t$val"; > } Or give the block a name (label), and have an index (or several indexes, like some that are reset by redo an some that are not) avai

Re: Implicit current-index variable, scoped inside for-loops

2006-08-29 Thread Ruud H.G. van Tol
Carl Mäsak wrote: > But maybe a variable that implicitly carries along the loop index > would be even snazzier? > > for @array -> $val { > say "$.\t$val"; > } Or give the block a name (label), and have an index (or several indexes, like some that are reset by redo an some that are not) availabl