Would people agree with the statement that to a large degree, using template
metaprogramming techniques turns a C++ compiler into a C++ interpreter (but
just for the metaprogrammed portions of the code)? It's not a perfect
analogy, but it seems to be a reasonable statement... 12 2161
"Dave" <be***********@ yahoo.com> wrote... Would people agree with the statement that to a large degree, using
template metaprogramming techniques turns a C++ compiler into a C++ interpreter
(but just for the metaprogrammed portions of the code)? It's not a perfect analogy, but it seems to be a reasonable statement...
Every compiler is an interpreter if it can handle things like
int a = 1 + 2 + 3 + 4;
by creating a definition of 'a' initialised to 10 instead of
a special piece of code that performs three additions with the
immediate operands.
Victor
"Dave" <be***********@ yahoo.com> wrote in message news:vu******** ****@news.super news.com... Would people agree with the statement that to a large degree, using template metaprogramming techniques turns a C++ compiler into a C++ interpreter (but just for the metaprogrammed portions of the code)? It's not a perfect analogy, but it seems to be a reasonable statement...
I wouldn't agree with the statement. It's more of a supercompiler as it
can precompute code at compile time as opposed to translating language
at run time.
"Victor Bazarov" <v.********@com Acast.net> wrote in message news:u8%Fb.1190 86$8y1.371001@a ttbi_s52... Every compiler is an interpreter if it can handle things like
int a = 1 + 2 + 3 + 4;
by creating a definition of 'a' initialised to 10 instead of a special piece of code that performs three additions with the immediate operands.
Every compiler has to be able to handle that. 1 + 2 + 3 + 4
is a constant expression.
The fact that a compiler can precompute things at compile
time makes it LESS of an interpreter than more of one in my
opinion.
Ron Natalie wrote: "Dave" <be***********@ yahoo.com> wrote in message news:vu******** ****@news.super news.com...
Would people agree with the statement that to a large degree, using template metaprogrammi ng techniques turns a C++ compiler into a C++ interpreter (but just for the metaprogrammed portions of the code)? It's not a perfect analogy, but it seems to be a reasonable statement...
I do see what you mean. You're getting the compiler to execute a
program for you, in much the same way that a Unix shell executes your
commands. However, the compiler is acting as a very special-purpose
interpreter, useful only for generating "traditiona l" code. The reason
is that run-time libraries, system interfaces, etc. are not available.
Ron Natalie wrote:
I wouldn't agree with the statement. It's more of a supercompiler as it can precompute code at compile time as opposed to translating language at run time.
I have to agree with Ron. The compiler is acting more like a CASE tool
than a traditional compiler. Speaking of which, whatever happened to
4GL's? Does C++ metaprogramming count?
-Jeff
"Jeff Schwab" <je******@comca st.net> wrote in message
news:G7******** ************@co mcast.com... Ron Natalie wrote: "Dave" <be***********@ yahoo.com> wrote in message
news:vu******** ****@news.super news.com...Would people agree with the statement that to a large degree, using
templatemetaprogrammi ng techniques turns a C++ compiler into a C++ interpreter
(butjust for the metaprogrammed portions of the code)? It's not a perfect analogy, but it seems to be a reasonable statement... I do see what you mean. You're getting the compiler to execute a program for you, in much the same way that a Unix shell executes your commands. However, the compiler is acting as a very special-purpose interpreter, useful only for generating "traditiona l" code. The reason is that run-time libraries, system interfaces, etc. are not available.
Yeah, this characterizatio n of template metaprogramming recently occurred to
me as I was trying my hand at a couple of miscellaneous problems just to see
if I could do it. I successfully implemented the compile-time calculation
of order statistics via template metaprogramming and it was at that point
the thought occurred to me that there is something sort of akin to
interpretation going on. Although, your point about the lack of
availability of any run-time libraries, etc... is well-taken!
Ron Natalie wrote:
I wouldn't agree with the statement. It's more of a supercompiler as
it can precompute code at compile time as opposed to translating language at run time.
I have to agree with Ron. The compiler is acting more like a CASE tool than a traditional compiler. Speaking of which, whatever happened to 4GL's? Does C++ metaprogramming count?
-Jeff
Dave wrote: "Jeff Schwab" <je******@comca st.net> wrote in message news:G7******** ************@co mcast.com...
Ron Natalie wrote:
"Dave" <be***********@ yahoo.com> wrote in message just for the metaprogrammed portions of the code)? It's not a perfect analogy, but it seems to be a reasonable statement...
I do see what you mean. You're getting the compiler to execute a program for you, in much the same way that a Unix shell executes your commands. However, the compiler is acting as a very special-purpose interpreter , useful only for generating "traditiona l" code. The reason is that run-time libraries, system interfaces, etc. are not available.
Yeah, this characterizatio n of template metaprogramming recently occurred to me as I was trying my hand at a couple of miscellaneous problems just to see if I could do it. I successfully implemented the compile-time calculation of order statistics via template metaprogramming and it was at that point the thought occurred to me that there is something sort of akin to interpretation going on. Although, your point about the lack of availability of any run-time libraries, etc... is well-taken!
So the question is - do you want metaprogramming in the regular language?
I've written a number of fancy templates and I find having to think in
this recursve "COME FROM" language a little bit of a challenge.
Then if you start to argue about this too much you'll have someone
remind you that lisp does all this in one language.
"Gianni Mariani" <gi*******@mari ani.ws> wrote in message
news:bs******** @dispatch.conce ntric.net... Dave wrote: "Jeff Schwab" <je******@comca st.net> wrote in message news:G7******** ************@co mcast.com...
Ron Natalie wrote:
"Dave" <be***********@ yahoo.com> wrote in message>just for the metaprogrammed portions of the code)? It's not a perfect >analogy, but it seems to be a reasonable statement...
I do see what you mean. You're getting the compiler to execute a program for you, in much the same way that a Unix shell executes your commands. However, the compiler is acting as a very special-purpose interpreter , useful only for generating "traditiona l" code. The reason is that run-time libraries, system interfaces, etc. are not available.
Yeah, this characterizatio n of template metaprogramming recently
occurred to me as I was trying my hand at a couple of miscellaneous problems just to
see if I could do it. I successfully implemented the compile-time
calculation of order statistics via template metaprogramming and it was at that
point the thought occurred to me that there is something sort of akin to interpretation going on. Although, your point about the lack of availability of any run-time libraries, etc... is well-taken!
So the question is - do you want metaprogramming in the regular language?
I've written a number of fancy templates and I find having to think in this recursve "COME FROM" language a little bit of a challenge.
Then if you start to argue about this too much you'll have someone remind you that lisp does all this in one language.
Yep, I agree with your sentiments! Not to mention that syntactically it's
awful. But that's not the fault of the language since templates weren't
envisioned to be used in this manner. Nonetheless, I find the concept of
compile-time programming (and especially that it is Turing-complete)
fascinating...
Gianni Mariani wrote: So the question is - do you want metaprogramming in the regular language?
I've written a number of fancy templates and I find having to think in this recursve "COME FROM" language a little bit of a challenge.
Then if you start to argue about this too much you'll have someone remind you that lisp does all this in one language.
So do a number of other interpreted languages, including Perl and Tcl.
I think that's why template-based metaprogramming reminded the OP of an
interpreted language.
"Dave" <be***********@ yahoo.com> wrote in message
news:vu******** ****@news.super news.com... Nonetheless, I find the concept of compile-time programming (and especially that it is Turing-complete) fascinating...
Well I thought I followed alot of this thread, but what's 'Turing-complete'
?
Is there an incomplete?
--
Cheers
--
Hewson::Mike
"This letter is longer than usual because I lack the time to make it
shorter" - Blaise Pascal This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave |
last post by:
For those who might be so inclined, I was wondering if I might get honest
critiques of my first real venture into template metaprogramming. This
template metaprogram sorts a list of integers at compile time. It works,
but if my approach is more awkward or "bad" than need be, I'd love to hear
suggestions for improvement!
#include <iostream>
|
by: Mohammad |
last post by:
Hi,
Is it possible to disable a method of a template class depending on
the typename at compile time?
thanks!
|
by: Protoman |
last post by:
I've been looking at template metaprogramming. It seems really cool,
make the compiler do most of the work. I have very simple program that
uses TMP,it calculates the square of a number, but it doesn't seem to
work. Here it is:
#include <iostream>
#include <cstdlib>
using namespace std;
template<int n>
|
by: Mark Stijnman |
last post by:
I am trying to teach myself template metaprogramming and I have been
trying to create lists of related types. I am however stuck when I want
to make a template that gives me the last type in a list. I started by
using a linked list of types with templates like:
struct MyClass1 {};
struct MyClass2 {};
struct MyClass3 {};
struct NullType {};
|
by: Joe |
last post by:
Hi,
I found a concept named template metaprogramming that can be used in C+
+ code at compile-time. I am a beginner at C++. But I am a programmer
on the .NET platform. Do you know if template metaprogramming is
supported in C# (.NET)? For reference I found it:
http://en.wikipedia.org/wiki/Template_metaprogramming.
Thanks to all.
| |
by: Ted |
last post by:
I have cross posted this to comp.lang.c++ and to sci.math.num-
analysis
in the belief that the topic is of interest to some in both groups.
I am building my toolkit, in support of my efforts in producing high
performance C++ code; code that is provably correct. The issue here
is orthogonal to the question of expression templates, which at
present seem to me to be relatively simple.
|
by: iapx86 |
last post by:
My parser project calls for a computed goto (see code below).
The C preprocessor delivers the desired result, but is ugly.
Template metaprogramming delivers results I do not understand.
Can anyone explain why loop unrolling doesn't play well with templates?
Or better, can someone submit a code fragment to get desired results?
Here are the command-lines I use to generate code:
"g++ -DTEMPLATE=0 -o gotofun0 gotofun.cpp" works exactly as...
|
by: stdlib99 |
last post by:
Hi,
I have a simple question regarding templates and meta programming.
I am going to try and work my way through the C++ Template
Metaprogramming, a book by David Abrahams and Aleksey Gurtovoy. I’m
not doing this because I want to be a Meta Programming guru (because a
lot of that stuff looks too crazy for use in the real world).
Rather I want to learn heavyweight templates and this is the only
|
by: nooneinparticular314159 |
last post by:
Hello. If I declare the following:
template<int a, int b, int SomeArray>
class DoSomething{
public:
..
..
..
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |