Mark Dominus on 12 Jan 2004 03:21:49 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: What use is the Schwartzian Transform?


Michael Cramer <cramer@webkist.com>:
> I disagree with the main assumption: I don't think C is particularly clear.

Interesting.

> Obviously, @filenames go in one side and come out the other side sorted 
> by whatever -M does. Structurally very clear.
> 
> >         # Code B 
> >         my @filenames = readdir D;
> >         @sorted = map { $_->[0] }
> >                   sort { $b->[1] <=> $a->[1] } 
> >                   map { [$_, -M $_] } @filenames;
> 
> Less clear, but even a quick glance tells me that @filenames are going 
> in one side and a sorted list of something comes out the other side.

Fair enough.  But why doesn't a quick glance tell you at least that
much about C, which has

> >         @sorted = sort { $date{$b} <=> $date{$a} } @filenames;


??  I would think that a quick glance at C would strongly suggest that
the filenames are being sorted by date, since the word 'date' is right
there in the sort comparator; there isn't anything similarly
documentative in B.

This is a serious question.

Finally:

> A quick glance says we're filling up a hash with some dates (with 
> @filenames, but the for loop is a bit unclear unless you use it that way 
> often). 

Suppose it had been written like this:

> >         for (@filenames) { $date{$_} = -M $_ }


.  Would you have liked it better?


-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**