Since I'm supposed to be summarizing this thread for Simon's weekly write-up, 
let me make sure I have the four(?) basic suggestions/stances.

1) There are too many variations/problems/issues to bother having Perl try to 
handle them all.  If folks want an optimized sort, they should continue to 
use the ST, or roll something similar.

2) Perl should create some form of special syntax explicitly for doing an ST 
on data.  (Other than the special syntax of the ST, of course.)

3) Perl should provide a general memoization mechanism, usable outside sort, 
but that could be used to get ST-like behavior from a regular sort routine.

      sort { f'($a) <cmp> f''($b) &| ... &| f``($a) <cmp> f`($b) } @list;  or
      sort { $a->f' <cmp> $b->f'' &| ... &| $a->f`` <cmp> $b->f` } @list;

Each value in list would have the results for f() cached for subsequent 
comparisons within the sort.  This would eliminate the need for the ST.

4) Should should grok a sort as an ST.

      sort { f'($a) <cmp> f''($b) &| ... &| f``($a) <cmp> f`($b) } @list;  or
      sort { $a->f' <cmp> $b->f'' &| ... &| $a->f`` <cmp> $b->f` } @list;

Perl should see this and think.... aha!

      map { $_->[0] } 
      sort { $a->[1] <cmp> $b->[2] &| ... &| $a->[-2] <cmp> $b->[-1] }
      map { [$_, f'($_), f''($_), ... , f``($_), f`($_)] } @list;

Did I grossly miss anyone's position?

On Wednesday 28 March 2001 15:02, Dan Sugalski wrote:
> At 11:59 AM 3/28/2001 -0500, John Porter wrote:
> >Dan Sugalski wrote:
> > >...
> > > subs inside the sort sub are called" then life becomes much easier.
> >
> >Easier for perl.  Don't we want to make life easier for the programmer?
> >I mean, in general, it would be nice if there were a way to have
> >perl memoize for us, rather than have to arrange it ourself.
> >It could benefit a lot of situations besides sorting.
>
> I'm not talking about making it easier on perl so much as making it faster.
> Basically to give us the wiggle room to recognize some simple constructs
> like
>
>     foo($a) <=> bar($b)
>
> or
>
>     foo($a) cmp bar($b)
>
> and optimize them to a table build and sort. This would work for plain perl
> data structures as well, as we might potentially be doing a fair amount of
> data conversion through the variable vtable interface. (Not to mention the
> issues of data mangling for proper Unicode sorting support)
>
>                                       Dan
>
> --------------------------------------"it's like this"-------------------
> Dan Sugalski                          even samurai
> [EMAIL PROTECTED]                         have teddy bears and even
>                                       teddy bears get drunk

-- 
Bryan C. Warnock
[EMAIL PROTECTED]

Reply via email to