On Fri, 11 Aug 2000, David L. Nicol wrote:
> I've started talking about "containers" instead of arrays and hashes
> since those both tie directly to implementation details, and containers
> are abstractions.
[...]
>
> If hashes normally had a sort method of null, they would work normally,
> but you could overload the sort method of any hash with
>
> methodoverloadoperator(%thehashinquestion, 'sort', {$a flubber $b})
>
> What is a better syntax for this?
How about:
%foo{ {$a <=> $b} }
(Obviously, you can put whatever you want as the sort function.)
Here are the advantages I see:
- minimum syntax required
- very clear what you're doing:
1) % is only used to refer to a hash as a whole
2) you generally don't use code refs as keys
Dave