On 18 Jul 2002 at 23:39, belg4mit wrote: > Heh I just came across this today. It's an interesting optimization, > but does it occur that often? It also precludes the possiblity of action at a > distance / more complicated sort blocks/subroutines doing more than just > sorting... > > Peter Makholm wrote: > > > > xyzzy% perl -le 'sort {print "a:$a\tb:$b"; $a cmp $b} qw(5 2 3 4 1)' > > xyzzy% > > > > Somehow the print statement isn't evaled. Playing a little more around > > I tried the following: > > > > xyzzy% perl -le '(sort {print "a:$a\tb:$b"; $a cmp $b} qw(5 2 3 4 1))' > > xyzzy% perl -le '(sort {print "a:$a\tb:$b"; $a cmp $b} qw(5 2 3 4 1))[3]' > > a:2 b:5
[...] What's the trick here --- is it that the sort isn't done *at*all* [it isn't that the side-effects aren't happening, but that the *SORT* isn't happening]? If so, that's pretty interesting --- how many other actions/operators just "go away" when evaluated in a void context ... Does a map in void context actually happen? /Bernie\ -- Bernie Cosell Fantasy Farm Fibers mailto:[EMAIL PROTECTED] Pearisburg, VA --> Too many people, too few sheep <--