in reply to Perl6 sorting

I agree that the sort proposed is a powerful and useful upgrade. DWIM is much better than looking up transforms and manuevers every one wants to do something a little subtle.

But I like Uri's key: syntax because it made it more explicit what this list of expressions is about. To my untrained eye perl5 eye, Damian's syntax looks like an anonymous array of ambiguous code blocks with funny annotations. The key: syntax feels more like natural language to me.

-Mark

Replies are listed 'Best First'.
Re: Re: Perl6 sorting
by TimToady (Parson) on Mar 03, 2004 at 16:59 UTC
    It would be easy to write something that translated a verbose sort spec into a concise one. A "key" macro would be able to process Uri's syntax directly, for instance. But it would probably only be useful in 1% of the time--nearly all sorts are trivial. And we're adding enough new "key" words to Perl 6 as it is...
      Yes, but what would be interesting is making an approximation of this as a Perl 5 module.

      The sorting part isn't hard, IMHO: you could translate the thing into a sort-of-Schwartizan transform where an array element would be either a key, or a coderef, and sort that fairly nicely.

      Finding a good way of passing all that data to a Perl5 routine, however, would be a challenge.

      Which, I think, is why Damian chose the theme. I don't think his point was the wonderfull multitude of things his sort is going to do, it's all the wonderfull ways of communicating with subroutines that the new syntax will make possible.