Re: RFC 124 (v1) Sort order for any hash : syntax as a macro, more laziness

2000-08-18 Thread David L. Nicol
Jonathan Scott Duff wrote: > > Does the presence of an ordering subroutine cause perl to generate a > linked list of all the elements of the %hash in the proper sequence > prior to iteration (and somehow attach it to the iterator)? Seems > like everytime we did that it would generate a new oper

Re: RFC 124 (v1) Sort order for any hash

2000-08-18 Thread Jonathan Scott Duff
On Fri, Aug 18, 2000 at 09:31:44AM +0100, Hildo Biersma wrote: > Ah, syntax - I have no idea. Well, syntax aside, how would this work? > One thing we could do, theoretically: > > %hash = ('James' => 'Gibbon', > 'Dave' => 'Mallon', > 'Pete' => 'Munro'); > > while (my ($key,

Re: RFC 124 (v1) Sort order for any hash

2000-08-18 Thread Hildo Biersma
"David L. Nicol" wrote: > > Hildo Biersma wrote: > > > > > =head1 ABSTRACT > > > > > > Herein a new syntax is introduced to specify a sort function > > > for the keys of any hash. > > > > > > =head1 DESCRIPTION > > > > > > %professors{ $a->name cmp $b->name }; > > > > I feel the sort orde

Re: RFC 124 (v1) Sort order for any hash

2000-08-18 Thread Hildo Biersma
> =head1 ABSTRACT > > Herein a new syntax is introduced to specify a sort function > for the keys of any hash. > > =head1 DESCRIPTION > > %professors{ $a->name cmp $b->name }; I feel the sort order should be specified on the iterator, not on the hash variable. It should be possible to

Re: RFC 124 (v1) Sort order for any hash

2000-08-17 Thread Damian Conway
> >>%professors{ $a->name cmp $b->name }; > >> > >>%students{ $$students{$b}{GPA} <=> $$students{$a}{GPA} }; > > > > These already mean something. Please don't "special-case" them. > > No they don't. Apologies. You're quite correct. > > Isn't this b

Re: RFC 124 (v1) Sort order for any hash

2000-08-17 Thread David L. Nicol
Damian Conway wrote: > >>%professors{ $a->name cmp $b->name }; >> >>%students{ $$students{$b}{GPA} <=> $$students{$a}{GPA} }; > > These already mean something. Please don't "special-case" them. No they don't. [david@nicol1 perl]$ perl -le '%nums = (1..20); print %nums{1}' C

Re: RFC 124 (v1) Sort order for any hash

2000-08-17 Thread Tom Hughes
In message <[EMAIL PROTECTED]> Perl6 RFC Librarian <[EMAIL PROTECTED]> wrote: > A "sort function" will need to be added into the list of magics > maintained for every associative array. > > A set of macros in terms of sort will need to be defined which > replace keys, values, and each f

Re: RFC 124 (v1) Sort order for any hash

2000-08-17 Thread Damian Conway
>%professors{ $a->name cmp $b->name }; > >%students{ $$students{$b}{GPA} <=> $$students{$a}{GPA} }; These already mean something. Please don't "special-case" them. Isn't this better handled with a (revamped and faster) tie? tie %professors, 'Tie::Sorted', ^a->name cmp