C++ now has lambdas [where the closed variables must be properly identified, types may have to be identified, and one has to explicitly say for the closed variables whether they are captured by reference or by value]. Very elegant! Robert On Mon, Apr 21, 2014 at 7:45 AM, Joerg Arndt <arndt@jjj.de> wrote:
* Henry Baker <hbaker1@pipeline.com> [Apr 21. 2014 17:28]:
This is precisely the trouble with templates:
you need to learn yet another language for what can be templated & what cannot. Adding in the C preprocessor, you now need to know 3 completely different languages in order to write these C++ programs.
The basic concept is very easy to grasp:
// A template function: template <typename Type> Type max(Type a, Type b) { if ( a>b ) return a; else return b; }
// A template class: template <typename Type> struct two_things { Type a, b; /* ... */ };
See?
Of course one can use templates to dispatch more than just "types", for example, allocators and algorithms. Programming this tends to be more interesting. However, _using_ the those things from the STL (standard template library) is not that hard.
So "need to learn yet another language" may only be true when you do template meta programming. But anyone doing this should have a very good pain tolerance anyway.
While there is a distinction between Lisp macros and Lisp functions, at least you can construct Lisp macros with standard Lisp functions.
A huge fraction of templating could be eliminated with proper function closures and proper "inlining". For example, most modern Lisps are capable of inlining mapping functions which apply functions given as arguments to sequences of various kinds. The lambda calculus tells us how to do these things correctly, if we will only listen.
C++ now has lambdas 8^)
Best, jj
[...]
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun