Re: Please suggest use-cases for introspective code generation
On Sep 8, 3:28 pm, Tony Delroy <tony_in_da...@yahoo.co.uk> wrote:
On Sep 8, 10:38 pm, Le Chaud Lapin <jaibudu...@gmail.com> wrote:
Sorry, but wrong. (I feel like I have an unfair example here, because
you're imagining abstract things that you believe are impossible, and
I've got a real system providing counter examples.) My system isn't
much different to PHP... where you're in an HTML document most of the
time, and you explicitly denote the sections for the PHP interpreter.
Substitute C++ and preprocessor. There is never any blurring of the
lines. Within both the C++ code outside the preprocessor and the C++
code specified for on-the-fly compilation, there are no new language
rules or hidden transformations (the closest is the implicit wrapping
of in-line code into a function with required prototype and argument
names). So far I have found no need- unlike in OpenC++ where it's a
requirement of the super-classing idiom - is transformation of
existing C++ code. In my experiments so far, it's been entirely
adequate to simply inject new code as required, and the locations for
this in typically at the point of invocation, but at worst is another
location explicitly marked by preprocessor escaping and a linking
Let me understand correctly. I _thought_:
1. You take a Pure C++ program.
2. Your preprocessor process that program, analyzes it, generates
3. For example, extra code might be generated as a library.
4. Your Pure C++ code can employ functions from that library.
If this is the case, it is "4" that I am concerned with. Even if not
one line of the Pure C++ code is changed, and you have a Pure C++
library that you can now use, the semantic issue still exists. What
is the generated code for, what will it do?
My assertion is that, because computers cannot think, whatever is done
with those libraries will not be automatic. You cannot, for example,
in general, generate correct code for serialization of a class without
annotating the orginal Pure C++ code. The annotation can be done
using one of two methods:
1. Use standard C++ constructs.
2. Use new keywords.
If "1" is used, the tedium involved will require the programmer to
think. But the whole reason for doing it was to relieve the programmer
of thinking. So if the programmer has to think too much while not
thinking, then the purpose is defeated.
If "2" is used, then it is a new language.
So only "1" needs to be considered. So as strange as it sounds, the
answer to your request is your request itself.
"Please suggest use-cases for introspective code generation"
could be reinterpreted as
"Please suggest use-cases for introspective code generation that is
compatible with C++ and does not require the programmer to deal with
tedium any more than he would have without such a facility."
If someone achieved this objective, in the context of serialization,
for example, I would be most impressed. If someone were to do this to
"auto-bind" member fields of objects to their corresponding GUI
controls, I would be impressed.
I guess what I am saying is...I would like to see an example, where,
after the thing to be concocted has been concocted, the programmer
really did save time by doing it using your pre-processing tool,
versus just accomplishing the same thing in Pure C++.
-Le Chaud Lapin-
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]