On Mon, Mar 26, 2001 at 10:50:09AM -0500, Uri Guttman wrote:
> >>>>> "SC" == Simon Cozens <[EMAIL PROTECTED]> writes:
> SC> Why can't Perl automagically do a Schwartzian when it sees a
> SC> comparison with complicated operators or functions on each side of
> SC> it? That is, @s = sort { f($a) <=> f($b) } @t would Do The Right
> SC> Thing.
>
> because that would require the PSI::ESP module which isn't working
> yet.
Not at all. Simon's example looks like a simple case of memoization.
The cache only needs to be maintained for the duration of the sort,
and it alleviates the need for complicated map{} operations.
> how would perl intuit exactly the relationship between the records
> and the keys extraction and comparison?
The key extraction is done with f(), and the comparison is done
with cached values of f().
Z.