473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C++ and dynamic programming

Does C++ support dynamic programming? I hope I'm using the correct
term. I want to write code that can dynamically rewrite itself! I want
to dynamically create functions and call them and etc. If not, are
there any plans to add support for it in the future? What other
popular programming languages support dynamic programming? [Email me
privately for the last question so that people will not complain that
it's out of context.]

--The Directive
Jul 22 '05 #1
5 2945
"The Directive" <th***********@hotmail.com> wrote in message
news:84**************************@posting.google.c om
Does C++ support dynamic programming? I hope I'm using the correct
term. I want to write code that can dynamically rewrite itself! I want
to dynamically create functions and call them and etc. If not, are
there any plans to add support for it in the future? What other
popular programming languages support dynamic programming? [Email me
privately for the last question so that people will not complain that
it's out of context.]


If you mean does C++ allow you to generate functions on the fly that are
identical to those produced at compile time, then the answer is no. C++ can,
however, be used to create an interpreter, i.e., a program that will allow
you to type in functions at runtime and will store and execute those
functions. Writing such a program involves some work, however (how much work
depends on the range of possible functions you wish to support).

Any function that you might write will be built up from basic operations
(built in operators like + as well as predefined functions like sin and
cos). Accordingly, an interpreter basically consists of a pre-written
all-purpose function that calls basic operations as needed by the function
that the user specifies at run-time (in the simplest case, it may involve a
switch statement that executes different operations depending on which
operation has been specified at run-time). For a simple illustration of how
this is done, look at the calculator program in Ch 6 (including exercise 20)
of Stroustrup's TC++PL.
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 22 '05 #2

"John Carson" <do***********@datafast.net.au> wrote in message
news:40********@usenet.per.paradox.net.au...
"The Directive" <th***********@hotmail.com> wrote in message
news:84**************************@posting.google.c om
Does C++ support dynamic programming? I hope I'm using the correct
term. I want to write code that can dynamically rewrite itself! I want
to dynamically create functions and call them and etc. If not, are
there any plans to add support for it in the future? What other
popular programming languages support dynamic programming? [Email me
privately for the last question so that people will not complain that
it's out of context.]


If you mean does C++ allow you to generate functions on the fly that are
identical to those produced at compile time, then the answer is no. C++ can,
however, be used to create an interpreter, i.e., a program that will allow
you to type in functions at runtime and will store and execute those
functions. Writing such a program involves some work, however (how much work
depends on the range of possible functions you wish to support).


Well , C++ can generate class hierarchies on the fly.
That means you can make the compiler generate it for you.
This involves using templates.
Take a look at Andrei Alexandrescu's "Modern C++ design" where he shows in
chapter 4 how to
generate linear and scattered class hierarchies at compile time.

Best wishes,
Sharad
Jul 22 '05 #3
Sharad Kala wrote:
Take a look at Andrei Alexandrescu's "Modern C++ design" where he shows in
chapter 4 how to
generate linear and scattered class hierarchies at compile time.

^^^^^^^^^^^^^^^
"Compile time" may or may not meet your definition of dynamic
programming, because it involves a compile/execute/modify-source loop.
It doesn't happen on what most people consider to be "the fly".

Jacques.

Jul 22 '05 #4

"Jacques Labuschagne" <ja*****@clawshrimp.com> wrote in message
news:ss********************@news02.tsnz.net...
Sharad Kala wrote:
Take a look at Andrei Alexandrescu's "Modern C++ design" where he shows in
chapter 4 how to
generate linear and scattered class hierarchies at compile time.

^^^^^^^^^^^^^^^
"Compile time" may or may not meet your definition of dynamic
programming, because it involves a compile/execute/modify-source loop.
It doesn't happen on what most people consider to be "the fly".


Yes..actually I do agree with you that it isn't exactly what people would say
dynamic programming.
In fact it uses static polymorphism.
My point was that you can make C++ to write code for you. This is unlike virtual
functions where the branch of execution to be selected
is dynamic, but the code for execution has already been hand-written by someone.

Best wishes,
Sharad
Jul 22 '05 #5
The Directive wrote:
Does C++ support dynamic programming? I hope I'm using the correct
term. I want to write code that can dynamically rewrite itself! I want
to dynamically create functions and call them and etc. If not, are
there any plans to add support for it in the future? What other
popular programming languages support dynamic programming? [Email me
your problem might be resolved using embeddable C/C++ interpreter Ch. It
allows you to generate C/C++ code source code/functions on the fly and
be called by your C/C++ binary application, or call back your binary
C/C++ functions.

you can take a look at
http://www.softintegration.com/solution/embedded/
http://www.softintegration.com/products/sdk/embedded_ch/

privately for the last question so that people will not complain that
it's out of context.]

--The Directive

Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Roel Wuyts | last post by:
CALL FOR CONTRIBUTIONS International Workshop on Revival of Dynamic Languages http://pico.vub.ac.be/~wdmeuter/RDL04/index.html (at OOPSLA2004, Vancouver, British Columbia, Canada, October...
11
by: Neuruss | last post by:
I've been reading an article published in E-Week entitled "Microsoft Lures Open-Source Programmer", which contains a definition for dynamic languages as follows: "Dynamic programming languages...
4
by: Leslaw Bieniasz | last post by:
Cracow, 20.10.2004 Hello, As far as I understand, the generic programming basically consists in using templates for achieving a static polymorphism of the various code fragments, and their...
6
by: chris | last post by:
Hi all, I need to know, what is the difference between dynamic memory allocation, and stack allocation ? 1. If I have a class named DestinationAddress, when should I use dynamic memory...
0
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab,...
0
by: alexandre.bergel | last post by:
Dear colleges, You might want to consider Dyla'07 as a good venue to present your work and your favourite programming language. Regards, Alexandre ...
5
by: Guillermo Schwarz | last post by:
C++ers, I have programmed in C++ since 1991 and I probably created my best abstraction layers in C++ in those days. Since 2001 I've been programming in Java (at first against my will, then I...
1
by: Tinku | last post by:
Hi friends I know Static Hashing and i know about Dynamic Hashing, still i have problem to make program with Dynamic Hashing I am new in "C" world, please help me, my problem is: i have to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.