From: Ken Wesson Subject: Re: Java vs C++ Newsgroups: comp.lang.java.programmer References: <4d4d585c$0$81476$e4fe514c@news.xs4all.nl> <4d4d60dc$0$23763$14726298@news.sunsite.dk> <4d4d8322$0$41117$e4fe514c@news.xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: $$-cwgml$lsc2q.news.x-privat.org Message-ID: <4d4f69fa@news.x-privat.org> Date: 7 Feb 2011 04:41:46 +0100 Organization: X-Privat.Org NNTP Server - http://www.x-privat.org Lines: 29 X-Authenticated-User: $$o-16a0wpsuhxkoyemw X-Complaints-To: abuse@x-privat.org Path: csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!gegeweb.org!newsfeed.x-privat.org!x-privat.org!not-for-mail Xref: csiph.com comp.lang.java.programmer:26180 On Sun, 06 Feb 2011 16:35:32 +0100, Thomas Richter wrote: > Joshua Cranmer wrote: >> On 02/05/2011 10:38 PM, Lawrence D'Oliveiro wrote: >>> In message<4d4d8322$0$41117$e4fe514c@news.xs4all.nl>, Silvio wrote: >>> >>>> And Lew is correct: templates and genercis are completely different >>>> beasts. >>> >>> “Completely” as in “having nothing in common”? Or is this some usage >>> of “completely” that I wasn’t aware of? >>> >>> Please explain. >> >> Templates in C++ are basically advanced macros--each invocation of a >> template type regenerates the class, so a Foo and a Foo >> are two completely different things. > > That's much more than a macro could do. Templates are a language of its > own, include syntax checks, etc. Quite unlike macros, they do not > substitute text patterns. Templates allow meta-programming, i.e. you can > use the compiler to generate code. And, of course, templates are quite > complex - very unlike the simple-minded preprocessor. I take it by "macros" you mean the simple-minded preprocessor macros of C and C++. Lisp has things it calls "macros" that are much more sophisticated, including syntax checks, etc., and are able to do everything C++ templates can do and then some. Common Lisp macros can generate templated CLOS classes, for instance.