On Wed, Dec 21, 2005 at 10:25:09AM -0800, Randal L. Schwartz wrote:
> >>>>> "Uri" == Uri Guttman <[EMAIL PROTECTED]> writes:
> 
> Uri> i will let damian handle this one (if he sees it). but an idea would be
> Uri> to allow some form ofkey extraction via a closure with lazy evaluation
> Uri> of the secondary (and slower) key.
> 
> I still don't see that.  I understand about the lazy key evaluation.
> However, the sort block in Perl5 contains more than just two key
> computations: it also contains the logic to decide *how* to compare
> the keys, and *when* more information is needed (a secondary key step,
> for example).  Not sure how you're going to replace that with just
> information about how to compute "a key".  I think you've had your head
> inside GRT for too long. :)
> 
> So, for the simple case (string sort against some function of each item),
> I can see the need for a good shortcut.  However, the general case (let
> me tell you how to sort two items), you'll still need a very perl5-ish
> interface.

If I understand the p6 way correctly (which is not necessarily
true :-) it provides the key computation function in addition to
the comparison function.  So, the key computation can return a
list of keys for each value (possibly in lazy not-yet-evaluated
for so that the computation is only incurred the first time that
that key component is actually used).  The comparison function
is often simpler than a p5 comparison function (because of the
existance of the key function and because of the smarter match
capabilities) but could still be as complicated a a p5 sort
comparison function for those rare cases that really need it.

-- 

Reply via email to