[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Convenient array & hash iterators & accessors

From: Branko Čibej <brane_at_wandisco.com>
Date: Fri, 06 Mar 2015 11:55:01 +0100

On 06.03.2015 11:30, Julian Foad wrote:
> Branko Čibej wrote:
>> I'm also *very* scared of the
>> implicit, hidden qsort in the sorted.
> It's invoked only if you write "..._SORTED()" or "..._sorted()". That's explicit and visible. What's so scary about that?

The term "sorted iteration" is ambiguous. In this case, it means "sort
the container, then iterate", which means it has a side effect. A more
common meaning is "iterate in sorted order, leaving the container
unchanged". See, for example, Python's sorted() generator adaptor.

It's much more visible and unambiguous to sort the container and then
iterate on the result. Iterations should not have side effects on the
container.

-- Brane
Received on 2015-03-06 11:55:33 CET

This is an archived mail posted to the Subversion Dev mailing list.