>>>>> "RLS" == Randal L Schwartz <merlyn@stonehenge.com> writes:

>>>>> "Uri" == Uri Guttman <[EMAIL PROTECTED]> writes:
  Uri> sorting in p6 is not at all like in p5. instead of coding up an explicit
  Uri> comparison code block and duplicating all the key access code (for $a
  Uri> and $b), you will specify how to extract/generate each key for a given
  Uri> record. this new syntax was posted by damian (who else) and it is very
  Uri> similar to the api in my p5 module sort::maker (we did discuss this
  Uri> api). i don't know if any A/E/S doc covers it but it is definitely in
  Uri> the archives. 

  RLS> I hope the old (perl5) way is still available as well.  There are times
  RLS> when parts of the comparison should be done lazily.  Consider two
  RLS> objects that have a value for a primary sorting order, but only
  RLS> for those which the value is the same, we fall back to a secondary
  RLS> sort key that is expensive to compute (like maybe calling a database).

  RLS> For these scenarios, specifying the sort comparison will be simpler
  RLS> and cheaper than specifying the sort key.

  RLS> So, we need both, but if we get only one, the Perl5 way is superior.

i will let damian handle this one (if he sees it). but an idea would be
to allow some form ofkey extraction via a closure with lazy evaluation
of the secondary (and slower) key. and if you need that feature then you
can't use the standard ST or GRT which preextract the keys. you could
mung the ST to do this with lazy eval support but not the GRT since it
packs the keys and there is no place to put in code for lazy keys. note
that the API damian proposed did not specify an implementation so this
could be supported internally at some point. and supporting the old
simple p5 sort shouldn't be a problem and is probably a good idea
anyhow. but the $a and $b will have to become $^a and $^b and be proper
params of a closure. i dunno if that will cause a speed hit as $a/$b we
designed to bypass the normal slow arg passing in p5.


Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Reply via email to