The care and feeding of S29 (Re: Better sort spec?)

2008-12-27 Thread Carl Mäsak
Carl ():
 S29 needs a lot of care and feeding of this type. I've made a long
 list of things that need attention -- might return to this thread
 early next week and paste that list, so that more hands can help.

Here is that list:

 http://use.perl.org/~masak/journal/38170

People can help by addressing the questions I raise (preferably in
their own threads), or by bravely* adding a missing function/method to
S29, which resides here in the Pugs repository:

 http://svn.pugscode.org/pugs/docs/Perl6/Spec/S29-functions.pod

* bravely, but after doing the appropriate research in the other spec
documents, and possibly after some discussion on #perl6 or p6l. :)

// Carl


Re: Better sort spec?

2008-12-16 Thread Larry Wall
On Fri, Dec 12, 2008 at 11:49:37PM -0500, Uri Guttman wrote:
: so you have not discovered something new in perl or perl6 regarding
: sorting. it has been covered and in depth but never properly integrated
: into the p6 docs.

It will be more useful if you comment relative to the existing design found in:

http://svn.pugscode.org/pugs/docs/Perl6/Spec/S29-functions.pod

Larry


Re: Better sort spec?

2008-12-13 Thread Carl Mäsak
Uri ():
 [...]

 well, it is sort (sic) of just like what damian posted almost 5 years
 ago. i found this post covers something very similar to the rakudo
 implementation. i can't seem to find this proposal in any of the
 synopses (at least a quick google search found nothing) so maybe it
 needs to be put in the specs/synopses.

I have a couple of patches waiting to be written and integrated into
S29. The addition of the new signature to sort is one of them. I
expect a sudden inflow of round tuits early next week.

// Carl


Re: Better sort spec?

2008-12-13 Thread Carl Mäsak
Carl ():
 I have a couple of patches waiting to be written and integrated into
 S29. The addition of the new signature to sort is one of them. I
 expect a sudden inflow of round tuits early next week.

Oh, and I now see that moritz++ went and simply added it. JFDI++.

S29 needs a lot of care and feeding of this type. I've made a long
list of things that need attention -- might return to this thread
early next week and paste that list, so that more hands can help.

// Carl


Re: Better sort spec?

2008-12-13 Thread Patrick R. Michaud
On Fri, Dec 12, 2008 at 11:49:37PM -0500, Uri Guttman wrote:
 
  @sorted = sort {(%M{$^a}//-M $^a) = (%M{$^b}//-M $^b)} @unsorted;
  @sorted = map $_[1], sort {$^a[0] = $^b[0]}, map [-M,$_], @unsorted;
 
 would both become:
 
  @sorted = sort {-M} @unsorted;

This prompted me to go review the file test operators so I could
say here's how it would work in Rakudo, and guess what I found:

The advantage of the method form is that it can be used in places that
require tighter precedence than C~~ provides:

sort { $^a.M = $^b.M }, @files

though that's a silly example since you could just write:

sort { .M }, @files

So it looks like at least this part of the spec already documents
the feature, which means it _is_ in the spec after all -- just not
in S29 (which is where we were looking for it).

Pm


Re: Better sort spec?

2008-12-12 Thread Uri Guttman
 TSN == Timothy S Nelson wayl...@wayland.id.au writes:

  TSN  Hi all.  I saw the new sort idea on the Rakudo blog:
  TSN http://www.rakudo.org/2008/12/its-sort-of-like.html

  TSN  ...and wondered if we can get it in the spec, as I haven't
  TSN  seen any discussion on it or anything.

well, it is sort (sic) of just like what damian posted almost 5 years
ago. i found this post covers something very similar to the rakudo
implementation. i can't seem to find this proposal in any of the
synopses (at least a quick google search found nothing) so maybe it
needs to be put in the specs/synopses.

http://groups.google.com/group/perl.perl6.language/msg/728e7246c0c6b95f

there was a whole series of threads about sorting at that time. 

the end of that post has this:

 @sorted = sort {(%M{$^a}//-M $^a) = (%M{$^b}//-M $^b)} @unsorted;

 @sorted = map $_[1], sort {$^a[0] = $^b[0]}, map [-M,$_], @unsorted;

would both become:

 @sorted = sort {-M} @unsorted;

Damian 

so you can see a similar single extract code for both $^a and $^b. and
this exists in perl5 in Sort::Maker (mine) and i think also in Perl6::Sort
(which is damian's). 

so you have not discovered something new in perl or perl6 regarding
sorting. it has been covered and in depth but never properly integrated
into the p6 docs.

thanx,

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
- Free Perl Training --- http://perlhunter.com/college.html -
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -