Could sort return its result?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Could sort return its result?

Reuben Thomas
At the moment, sort seems to return nothing. Could it return its result
instead? This is useful for idioms such as

return sort (...)

and anything else where you want to continue to use the value.

-- 
http://www.mupsych.org/rrt/ | maximiste, n.  pessimiste (Roux)


Reply | Threaded
Open this post in threaded view
|

Re: Could sort return its result?

Roberto Ierusalimschy
> At the moment, sort seems to return nothing. Could it return its result
> instead? This is useful for idioms such as
> 
> return sort (...)

Our concern is that such idiom may lead users to forget that sort does
its job in place.


-- Roberto

Reply | Threaded
Open this post in threaded view
|

Re: Could sort return its result?

Reuben Thomas-5
> > At the moment, sort seems to return nothing. Could it return its result
> > instead? This is useful for idioms such as
> > 
> > return sort (...)
> 
> Our concern is that such idiom may lead users to forget that sort does
> its job in place.

Fair enough. I'm happy to have my own wrapper for sort which does
return the result (and I suppose I should also *not* sort in-place, so
that it is properly functional).

-- 
http://www.mupsych.org/rrt/ | art, n.  romanticized mundanity