Re: What has C++ become?
On Jun 12, 8:30 pm, Walter Bright <wal...@digitalmars-nospamm.com>
wrote:
Pascal J. Bourguignon wrote:
Noah Roberts <u...@example.net> writes:
You're calling the STL "low level code" when it is, in fact, high
level code. The find_if algorithm, for instance, is a high level
algorithm that can be used with any data type that obeys the iterator
abstraction.
No. find_if is low level.
Compare:
Key k;
std::vector<Element> v;
std::vector<Element>::iterator end=v.end();
std::vector<Element>::iterator found;
found=find_if(v.begin(),end,boost::bind(&Key::equal,k,boost::bind(=
&Element::getKey,_1)));
if(found==end){
doSomething(v,NULL);
}else{
doSomething(v,*found);
}
vs.
(lambda (k v) (do-something v (find-if (lambda (e) (equal k (get-key=
e))) v)))
The STL code is a fairly straightforward translation into the D
programming language:
import std.algorithm;
Key k;
Element[] v;
auto found = find!("k == a.getKey()")(v);
if (found == end(v))
doSomething(v, null);
else
doSomething(v, *found);
In this specific example, lisp is even higher level (ie.
more concise):
I'm not sure I agree with your definition of higher level
being more concise. Doesn't higher level mean more abstract?
In the context being considered (where "highest level" ==
"application"), a rough first approximation is that "higher
level" means that it depends on some "lower level". Lowest
level is thus the compiler with its constituant libraries and
the OS. Highest level is the function main().
Although this doesn't map directly to abstraction, it is
somewhat related: at the application level, you deal with very
concrete types: ClientOrder, Affectation, etc. Types that are
very far removed from the machine hardware, or even what the
language offers directly. At the lowest level, you'd probably
be talking about electrons, but of course, you don't go down to
that level in C++; for pratical purposes, in this group, the
lowest level is C++ and the OS API.
Pascal's point is, no doubt, that Lisp is further from the
actual hardware (and thus higher level) that is C++. At least
in this one particular case---I'm not convinced that it would
generalize to all cases. And I don't quite see how it is
relevant here.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34