Re: RFC 120 (v2) Implicit counter in for statements, possibly$#.

2000-08-31 Thread David L. Nicol
Chaim Frenkel wrote: > > This is making the index variable into an a wrapper object. No it isn't. Or at least it doesn't have to. Often there is a need to find the key an object was found in a container. More often in hashes than in arrays. And I think this discussion belongs in -data.

Re: RFC 120 (v2) Implicit counter in for statements, possibly$#.

2000-08-30 Thread Chaim Frenkel
This is making the index variable into an a wrapper object. Since the underlying value can't (or shouldn't) know which of the n containers it is in. > "JSD" == Jonathan Scott Duff <[EMAIL PROTECTED]> writes: JSD> Interesting. I must have missed this. I'm not wild about the syntax, JSD>

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-30 Thread Tom Christiansen
>What happened to the --nice, elegant and sparse array friendly-- >extension of each/keys/values? Well, there's already delete. I suppose those will come. But first we need a sparse-array friendly intenral representation, no? I always tell people to use hashes for sparse arrays. --tom

Re: RFC 120 (v2) Implicit counter in for statements, possibly$#.

2000-08-30 Thread Tom Christiansen
>I don't think anyone *needs* this, it would just be a nice syntactic >sugar. Haven't you ever coded a foreach loop only to realize later >that you need the index of the thing you've iterated to? Wouldn't it >be nice to just have access to it rather than hoop-jumping a little? On rare not commo

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-30 Thread Johan Vromans
John McNamara <[EMAIL PROTECTED]> writes: > As far as I can see the current consensus is as follows: > 1. Implicit variable: nice but not really worth the trouble. > 2. Explicit variable between foreach and the array: might conflict > with other proposals. > 3. Explicit cou

Re: RFC 120 (v2) Implicit counter in for statements, possibly$#.

2000-08-30 Thread Jonathan Scott Duff
On Wed, Aug 30, 2000 at 08:18:08AM -0600, Tom Christiansen wrote: > I don't perceive why this is so common a need as to require special > magic. And for those cases, a three-part for(;;) loop handles it, > since that tells you the index number directly. Could someone > explain why they need this

Re: RFC 120 (v2) Implicit counter in for statements, possibly$#.

2000-08-30 Thread Tom Christiansen
>Interesting. I must have missed this. I'm not wild about the syntax, >but I like the idea. If everything become objects under-the-hood, >then we could have: > for $a (@array) { print "$a is at $a->index\n"; } >No, I'm not wild about that either, but it's an idea. I don't perceive why

Re: RFC 120 (v2) Implicit counter in for statements, possibly$#.

2000-08-30 Thread Jonathan Scott Duff
On Tue, Aug 29, 2000 at 05:51:44PM -0500, David L. Nicol wrote: > I'd like to see a last-container-key attribute included as > a possibilty; and that attribute called ":n" to match the > argument of integer functions in introductory algebra. This > approach gives us > > for $a @some_list {

Re: RFC 120 (v2) Implicit counter in for statements, possibly$#.

2000-08-29 Thread David L. Nicol
I'd like to see a last-container-key attribute included as a possibilty; and that attribute called ":n" to match the argument of integer functions in introductory algebra. This approach gives us for $a @some_list { print "$a is located at position ${a:n}\n"; };

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-29 Thread Steve Simmons
On Tue, Aug 29, 2000 at 09:15:35AM +0100, John McNamara wrote: > At 13:11 28/08/00 -0400, Steve Simmons wrote: > >To tell the truth, this third item should probably should become > >a separate RFC, and if you'd like to simply say one is forthcoming, > >that'd be fine by me. > > What I really want

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-29 Thread John McNamara
At 08:19 29/08/00 -0500, Jonathan Scott Duff wrote: > > As far as I can see the current consensus is as follows: > > 1. Implicit variable: nice but not really worth the trouble. > > 2. Explicit variable between foreach and the array: might conflict > > with other proposals. > >

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-29 Thread Jonathan Scott Duff
On Tue, Aug 29, 2000 at 09:15:35AM +0100, John McNamara wrote: > At 13:11 28/08/00 -0400, Steve Simmons wrote: > >To tell the truth, this third item should probably should become > >a separate RFC, and if you'd like to simply say one is forthcoming, > >that'd be fine by me. > > What I really want

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-29 Thread John McNamara
At 13:11 28/08/00 -0400, Steve Simmons wrote: >To tell the truth, this third item should probably should become >a separate RFC, and if you'd like to simply say one is forthcoming, >that'd be fine by me. What I really want to do is write a summary, get some consensus and redraft the RFC. I'll do

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-28 Thread Steve Simmons
On Thu, Aug 17, 2000 at 08:46:53PM -, Perl6 RFC Librarian wrote: > This and other RFCs are available on the web at > http://dev.perl.org/rfc/ > > =head1 TITLE > > Implicit counter in for statements, possibly $#. Having read over the entire discussion, I want to make a few comments and thr

RFC 120 (v2) Implicit counter in for statements, possibly $#

2000-08-23 Thread Eric J. Roode
Many people have commented on this, and made good suggestions, with the trend generally heading toward explicit counters rather than implicit counters. I won't add to that drift, except to request that *if* an implicit solution is implemented ($# was suggested in the original RFC), that the im

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-20 Thread Peter Scott
At 08:19 AM 8/20/00 +0100, Graham Barr wrote: >Yes. I thought someone else would have done an RFC for this by >now, but I was going to propose that a for loop can >have any number of variables > > for my($a,$b,$c) (@array) { ... } > >steps three at a time, > > for my($key,$val) = (%hash) { ...

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-20 Thread Graham Barr
On Sat, Aug 19, 2000 at 09:23:03AM -0400, Ken Fox wrote: > "Christopher J. Madsen" wrote: > > foreach $item $index (@array) { > > print $item, " is at index ", $index, "\n"; > > } > > That's useful syntax, but I'd rather it mean stepping > pair-wise through @array. Then we could scan

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-19 Thread John McNamara
There have been several good suggestions. We'll leave the discussion run for another few days and then I'll try to summarise the main points in a single post. John -- "The Mosaic code has replaced the law of the jungle." James Joyce - Ulysses

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-19 Thread Johan Vromans
Mike Pastore <[EMAIL PROTECTED]> writes: > I like the proposed syntax! I also think that C would be > useful, ... Seconded. It nicely fits in the current way each() is used and no backward incompatibilties. Especially when iterating sparse arrays. while (($index,$value) = each(@sparse_array))

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-19 Thread Ken Fox
"Christopher J. Madsen" wrote: > foreach $item $index (@array) { > print $item, " is at index ", $index, "\n"; > } That's useful syntax, but I'd rather it mean stepping pair-wise through @array. Then we could scan through a hash with foreach $key $value (%hash) { ... } (Hashes are

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-18 Thread David L. Nicol
Mike Pastore wrote: > > On 18 Aug 2000, Ariel Scolnicov wrote: > > > Actually, this suggests that C should return > > C<(@array)> (a copy of the values), and C the list > > C<(0..$#array)>. But those aren't very useful. > > I like the proposed syntax! I also think that C would be > useful, I o

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-18 Thread Buddha Buck
At 11:21 PM 8/18/00 +0300, Ariel Scolnicov wrote: >Actually, this suggests that C should return >C<(@array)> (a copy of the values), and C the list >C<(0..$#array)>. But those aren't very useful. I dunno... my @a :sparse; @a[1,5] = (1,1); @k = keys @a; print "@k";# prints "1,2,3,4,5" or "1

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-18 Thread Mike Pastore
On 18 Aug 2000, Ariel Scolnicov wrote: > Actually, this suggests that C should return > C<(@array)> (a copy of the values), and C the list > C<(0..$#array)>. But those aren't very useful. I like the proposed syntax! I also think that C would be useful, I often use arrays as integer-based lookup

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-18 Thread Ariel Scolnicov
"Christopher J. Madsen" <[EMAIL PROTECTED]> writes: > Jonathan Scott Duff writes: > > Excellent summary of why an explicit index is a Good Thing as compared > > to the programmer doing it himself. I think the syntax would need to > > be different though, how do you use implicit $_ and an inde

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-18 Thread Nathan Torkington
Perl6 RFC Librarian writes: > foreach $item (@array) { > print $item, " is at index ", $#, "\n"; > } > > > The variable C<$#> currently holds the output format for printed > numbers. This would slow down all foreach loops, even those that didn't need to know $#. It's a similar

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-18 Thread Christopher J. Madsen
Jonathan Scott Duff writes: > On Fri, Aug 18, 2000 at 10:12:02AM -0500, Christopher J. Madsen wrote: > > foreach $_ $index (@array) { ... } > > > > It's only 3 characters, and it makes for a nice consistant syntax. > > Yep, but it might also be a source of confusion too. There's no wa

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-18 Thread Jonathan Scott Duff
On Fri, Aug 18, 2000 at 10:12:02AM -0500, Christopher J. Madsen wrote: > I would say you can't use implicit $_ with an index; you use explicit > $_ instead. Sounds like "Don't Do That" to me :-) > > foreach $_ $index (@array) { ... } > > It's only 3 characters, and it makes for a nice cons

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-18 Thread Christopher J. Madsen
Jonathan Scott Duff writes: > Excellent summary of why an explicit index is a Good Thing as compared > to the programmer doing it himself. I think the syntax would need to > be different though, how do you use implicit $_ and an index? (Don't > Do That is not an answer because people will wa

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-18 Thread Jonathan Scott Duff
On Fri, Aug 18, 2000 at 09:07:31AM -0500, Christopher J. Madsen wrote: [ Very Good examples elided ] > With the explicit counter, > > foreach $item $index (@array) { ... } > > $index could (and should) be a read-only variable (like $i is in > "foreach $i (1,2,3,4)"). This would make sure

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-18 Thread Christopher J. Madsen
David L. Nicol writes: > Why not use an explicit perl5 counter? > > my $index; > foreach $item (@array){ $index++; > print $item, " is at index ", $index, "\n"; > } Well, one reason is that your example doesn't work (it starts the index at 1 instead of 0). You'd need

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-17 Thread David L. Nicol
"Christopher J. Madsen" wrote: > Why not use an explicit counter instead? Something like > > foreach $item $index (@array) { > > (This is a syntax error in Perl5.) Why not use an explicit perl5 counter? my $index; foreach $item (@array){ $index++; print $i

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-17 Thread Glenn Linderman
Could also use this for foreach $item $key ( %hash ) { print "$item is indexed by $key\n"; } "Christopher J. Madsen" wrote: > I don't see why this should be an implicit counter. This (might) > cause extra work for every foreach loop in every program (depending on > how foreach is impl

Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-17 Thread Christopher J. Madsen
I don't see why this should be an implicit counter. This (might) cause extra work for every foreach loop in every program (depending on how foreach is implemented). Why not use an explicit counter instead? Something like foreach $item $index (@array) { print $item, " is at index ", $

RFC 120 (v2) Implicit counter in for statements, possibly $#.

2000-08-17 Thread Perl6 RFC Librarian
This and other RFCs are available on the web at http://dev.perl.org/rfc/ =head1 TITLE Implicit counter in for statements, possibly $#. =head1 VERSION Maintainer: John McNamara <[EMAIL PROTECTED]> Date: 16 Aug 2000 Last-Modified: 16 Aug 2000 Version: 2 Mailing List: [EMAIL PROTECTED