On Fri, Jul 19, 2002 at 07:42:53AM -0400, Bernie Cosell wrote:
>
> 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]?

The sort isn't happening. How would you imagine the sort to happen, but
not the side effects?

> 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 actuall
> happen?


Yes, and that's certainly a good thing. Maps in void context are useful,
for instance to get the sum of a list of numbers:

    map {$sum += $_} @array;
    
(Yes, and before you go chanting "but that can be done with a 'for'",
 let me point out that any while/for/until can be done with a 'goto',
 but that's not a reason to not use while/for/until, is it?).
 
 
The side effects of 'sort' are less useful, as the language doesn't
specify how often the block is called, or with which arguments. It's
implementation defined, and for instance, will differ between 5.6.1
and 5.8.0.
 
 
 
Abigail

Reply via email to