Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-12-15 12:45:08


Peter, this is too cool!

----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>

> The result is at the end of this message; I'd be interested to compare it
> with Dave's original compile-time sort, or another MPL-based or influenced
> sort.

I just wrote an insertion sort; I didn't have the presence of mind to
implement QuickSort. You da MAN!

> * MPL is dominated by an iterative idiom, AFAICS. Nearly everything is
done
> with a for-style loop. This might have its benefits (more gentle learning
> curve for C++/STL programmers) but I think that the recursive style of
> programming sometimes produces more elegant and readable functions.

That is certainly true for quicksort, at least after each partition.
In other words, an interative-style select_if (filter) is fine, but of
course it makes sense to recurse when you sort each half.

> * MPL tries to emulate the STL to the extent of using iterators into
> abstract sequences, and providing different 'containers' with their
> associated 'traits.' It even has a 'clear' function that returns a new
empty
> 'container' of the same type.

FWIW, I seldom used the iterators. On the other hand, I was not often
working with subranges of my sequences. I don't know how MPL iterators are
implemented, but I can imagine that it might be more efficient to use them
than to build a completely new sequence for each subrange in some cases.

> Both approaches have pros and cons. I prefer the traditional Lisp way.
> Without a motivating example to the contrary, I'm inclined to think that
in
> this area MPL is over-generic.

I'm inclined to agree, but am afraid to say so; every time I think something
like that I quickly find out that I've underestimated Aleksey's foresight.
;-)

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk