develooper Front page | perl.perl6.language.objects | Postings from August 2000

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

From:
David L. Nicol
Date:
August 17, 2000 23:50
Subject:
Re: RFC 124 (v1) Sort order for any hash
Message ID:
399CDC7C.556CDC06@kasey.umkc.edu

> > Isn't this better handled with a (revamped and faster) tie?
> >
> >         tie %professors, 'Tie::Sorted', ^a->name cmp ^b->name;
> >
> >         tie %students, 'Tie::Sorted',
> >                        $$students{^1}{GPA} <=> $$students{^0}{GPA} };
> >
> > Damian
> 
> It's a shorthand for it.

And the other thing, I don't want to overload everything, just the
iterator.  And not really so much to have sorted hashes, but to explore
syntaces for getting into the internals of the containers without
defining entirely new containers (tie)


How about
	
	%students : ( sort = $$students{^1}{GPA} <=> $$students{^0}{GPA} });

which uses the C< : qualifier> syntax to indicate a new-with-perl6 thing,
and uses it in a new way, assigning a value to the qualifier, as indcated
by the round brackets.


Suggesting that qualifiers can be assigned to, as well as flagging.


-- 
                          David Nicol 816.235.1187 nicold@umkc.edu
                      Does despair.com sell a discordian calendar?



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About