Talk:Template metaprogramming: Difference between revisions
BrainRepair (talk | contribs) |
|||
Line 65: | Line 65: | ||
In C++ macros are expanded by the preprocessor... I am not sure if this sentence is precise. |
In C++ macros are expanded by the preprocessor... I am not sure if this sentence is precise. |
||
[[User:Dpser|Dpser]] 16:57, 27 September 2007 (UTC) |
[[User:Dpser|Dpser]] 16:57, 27 September 2007 (UTC) |
||
== Any Way to Expand Macros and Templates into code for source level debugging? == |
|||
This gets around the argument that template code can be arcane/hard to understand. Basically multiple views of the same source code, and probably a nice learning tool. |
Revision as of 12:31, 16 April 2008
C/C++ Unassessed | ||||||||||
|
This was redirected to Talk:Generic, but no longer needs to since template metaprogramming is now described correctly. (well, let me know if it isn't correct!-)
D
Hmm, a recent edit added TMP code for factorials in D. Since this article is very C++ish the edit is out of place with the rest of the article. Either the article should be reworked to accomodate other languages, or something else need to be done... Mikademus 11:41, 19 March 2006 (UTC)
- Considering that most other languages don't support template metaprograms, it's unsurprising that C++ is the only language mentioned. And considering that and the fact that D isn't especially widely used, it probably would make sense to delete it. 68.238.86.68 14:07, 28 May 2006 (UTC)
- Since no objections has been voiced I removed it per suggestion above. The D-example was redundant and contributed no further information to TMP. The article consitently uses C++ as a vehicle, which is proper since it is the utterly dominant language with TMP facilities, and if other languages should be mentioned it should be through wikilinks to the relevant section in that language's article. I also rephrased a D-advocating edit in the "benefits and drawbacks" section. Mikademus 07:03, 19 July 2006 (UTC)
- If this is to be a C++ only article, it should be renamed "C++ Template Metaprogramming." But it is not so named, and it is common practice in Wikipedia to illustrate programming technique articles with how they work in various languages. The D programming language's template metaprogramming facilities are in many ways more powerful than C++'s. The D example should be put back in.
- The article is not about a comparison of different languages' TMP facilities, but a discussion of TMP using C++ as the illustration. Whether D is superior or not is beside the point - wikipedia is not a place for language holy wars. The article has been rephrased to drive this point home further. The rationale behind useing C++ is that it is the dominant and most used language for this, has the most significant literature on the topic to rely opun, and thus is for all purposes the most beneficial example for the readers. Examples using other languages does not contribute to the topic, unless it is of another aspect of TMP not supported by C++. In fact, since D templates is close to being syntax-synonymous with normal functions if D was used there would be need be no need for example code. Mikademus 10:27, 22 July 2006 (UTC)
- No, it's not a language holy war, simply because there's no contest. You say "The article has been rephrased to drive this point home further", I say the article has been hijacked to prevent D from showing up. If you want to talk about C++ TMP, then do that in a different article. This article is called "Template metaprogramming", not "C++ Template metaprogramming". I think the only reason you are deleting D examples is because you're ashemed of C++ template syntax. (can you prove me wrong?)
- The article is not about a comparison of different languages' TMP facilities, but a discussion of TMP using C++ as the illustration. Whether D is superior or not is beside the point - wikipedia is not a place for language holy wars. The article has been rephrased to drive this point home further. The rationale behind useing C++ is that it is the dominant and most used language for this, has the most significant literature on the topic to rely opun, and thus is for all purposes the most beneficial example for the readers. Examples using other languages does not contribute to the topic, unless it is of another aspect of TMP not supported by C++. In fact, since D templates is close to being syntax-synonymous with normal functions if D was used there would be need be no need for example code. Mikademus 10:27, 22 July 2006 (UTC)
- If this is to be a C++ only article, it should be renamed "C++ Template Metaprogramming." But it is not so named, and it is common practice in Wikipedia to illustrate programming technique articles with how they work in various languages. The D programming language's template metaprogramming facilities are in many ways more powerful than C++'s. The D example should be put back in.
- Since no objections has been voiced I removed it per suggestion above. The D-example was redundant and contributed no further information to TMP. The article consitently uses C++ as a vehicle, which is proper since it is the utterly dominant language with TMP facilities, and if other languages should be mentioned it should be through wikilinks to the relevant section in that language's article. I also rephrased a D-advocating edit in the "benefits and drawbacks" section. Mikademus 07:03, 19 July 2006 (UTC)
- I am a strong supporter of D and I refuse to use C++. However, for the sake of sticking to the topic of template metaprogramming, I can see that having all the example code in just one language an advantage for the topic. And as C++ literature out numbers D literature by astronomical dimensions, it seems reasonable to use C++ as the language of choice for examples in this topic. Of course I'd prefer to use D because (IMNSHO) its template implementation outshines C++'s, but that is not the point here. Maybe someone can start a page to demonstrate the differences in the various template implementations out there in the wild. DerekP 11:23, 23 July 2006 (UTC)
- I know very little of D, but if its template implementation offers any advantages for template metaprogramming over C++'s, then I'd like them in the article. I've searched through the history, but no edit summary includes " D ". --MarSch 19:37, 11 December 2006 (UTC)
- It's been a while, but IIRC in the article version discussed above D was used just for the sake of mentioning D. The principles of TMP are the same in C++ and D; D has modified up some of C++'s template semantics (for better or worse is up to personal preferences) but the capabilities are the same. C++ is simply used in the article as it is the more recognised and common language. Any D programmer can understand and adapt the C++ code presented here, but not vice versa. Mikademus 22:05, 11 December 2006 (UTC)
- I found it (http://en.wikipedia.org/enwiki/w/index.php?title=Template_metaprogramming&diff=64616972&oldid=64616688). Doesn't seem to add any value. --MarSch 12:24, 12 December 2006 (UTC)
Wow! or Eeeewwww!
I don't know whether to be impressed or disgusted... supposedly it was the intention of the designers of C++ to eliminate the need for macros and tricky macro-based techniques. But now it appears that when they introduced templates, they opened the door to a whole new avenue for creative, uh, hacking?
Now that I have learned about this astonishing technique, I am going to try very hard to forget it. I think I'm going to go away now and write some programs in TECO. Dpbsmith 01:41, 9 Jan 2004 (UTC)
- As a counterweight to the opinion below (now above --MarSch) I have to say that I've never yet in any other language found another tool as powerful as templated metaprogramming. It has given me freedom to write incredibly terse and efficient code. Yes, it is difficult to get into, but then again, so is programming. It looks daunting, heck, it is daunting, but so are real-life powertools. Mikademus 18:27, 20 November 2005 (UTC)
- As a countercounterweight to what is said below. C++ template metaprogramming is a poor man's version of a number of language features found in a wide variety of languages such as macros in Lisp. It's daunting because it's accidental, not designed, so it lacks proper support (poor error reporting, inconsistency and non-orthogonality, poor compiler implementation and so on). The fact that it's daunting has little to do with its power which is no different from that of any other language with staged computation. Sigfpe 22:00, 21 July 2006 (UTC)
Fixed top-posting of previous statements. --MarSch 19:24, 11 December 2006 (UTC)
- Coincidentally I have just added a reference to a review which mentions template metaprogramming as poor Lisp macros and the nice quote. As it turns out Scheme > C++ --MarSch 19:26, 11 December 2006 (UTC)
MPSH book
The book Metaprogramming GPUs with Sh actually doesn't have anything to do with template metaprogramming. The word in the title refers to run-time metaprogramming, as opposed to compile time metaprogramming. Sh is a runtime-embedded DSL in C++.
I'm not sure exactly what do with this. As one of the authors of that book, I can say that we're now avoiding the term metaprogramming more and more, because of this common confusion.
I'm leaving in the reference for now, but someone might want to either remove or clarify it.User:Sdt [1]
- I've removed it for now. --MarSch 19:28, 11 December 2006 (UTC)
Eiffel, Haskell, ML?
Eiffel, Haskell and ML are mentioned as a language supporting TMP. How?
Eiffel: Bertrand Meyer's book (2nd ed, 1997) only mentions templates in connection to C++, and manages to bad-mouth them fairly thoroughly in just one paragraph. Meyer doesn't strike me as the kind of person who happily steals successful ideas from C++, either ...
Haskell and ML: these support generic programming well, but that's not the same thing as TMP, is it? I see an external link to "Template Haskell". Following that link, it's clear that this is not Haskell, but an extension to Haskell, i.e. a different language.
"A macro, which is also a compile-time language feature"
In C++ macros are expanded by the preprocessor... I am not sure if this sentence is precise. Dpser 16:57, 27 September 2007 (UTC)
Any Way to Expand Macros and Templates into code for source level debugging?
This gets around the argument that template code can be arcane/hard to understand. Basically multiple views of the same source code, and probably a nice learning tool.