La metatagina dei template è stata scoperta "per caso"? [chiuso]

3

Quando ho visto questo meme per la prima volta:

Ho pensato tra me, sì giusto , ma ora non ne sono più sicuro. Quindi era la meta-programmazione modello in C ++ scoperta per caso come afferma il meme o era intenzionale?

Did Bjarne & co in realtà lo fanno senza rendersi conto del potenziale?

    
posta Lennart Rolland 25.11.2016 - 19:19
fonte

2 risposte

6

C'è molto di più nell'inventare che dare una semplice lista di implicazioni e con C ++ Stroustrup mirato alla generalità:

I'm not interested in a language that can only do what I can imagine

Si tratta di Non hai davvero capito cosa stavi facendo? :

This one seems very popular. Or rather, it seems to be popular to assert that I had no clue so that C++'s success is some kind of accident. Yes, such statements annoy me, because they dismiss my work over decades and the hard work of many of my friends.

Let's first be perfectly clear: No, I did not anticipate the run-away success of C++ and no, I did not forsee every technique used with C++ or every application of C++. Of course not!

However, statements like these are very misleading:

  • Bjarne doesn't understand C++!
  • Bjarne didn't anticipate RAII and deterministic destruction!
  • Bjarne didn't anticipate template-metaprogramming!

I did outline the criteria for the design and implementation of C++. I did explicitly aim for generality: "I'm not interested in a language that can only do what I can imagine" and for efficiency "a facility must not just be useful, it must be affordable."

[CUT]

I was very surprised when Jeremy Siek first showed my the compile-time if that later became std::conditional, but I had aimed for generalty (and gotten Turing completeness modulo translation limits). I opposed restrictions to C++ immediately when Erwin Unruh presented what is widly believed to be the first template metaprogram to the ISO Standards committee's evolution working group. To kill template-metaprogramming, all I would have had to do was to say nothing. Instead my comment was along the lines "Wow, that's neat! We mustn't compromise it. It might prove useful." Like all powerful ideas, template-metaprogramming can be misused and overused, but that does not imply that the fundamental idea of compile-time computation is bad. And like all powerfuls ideas, the implications and techniques emerged over time with contributions from many individuals.

    
risposta data 26.11.2016 - 09:55
fonte
4

Il seguente estratto è soggetto a: link

History of TMP

Historically TMP is something of an accident; it was discovered during the process of standardizing the C++ language that its template system happens to be Turing-complete, i.e., capable in principle of computing anything that is computable. The first concrete demonstration of this was a program written by Erwin Unruh, which computed prime numbers although it did not actually finish compiling: the list of prime numbers was part of an error message generated by the compiler on attempting to compile the code.

Fonte: link

    
risposta data 25.11.2016 - 19:26
fonte