473,881 Members | 1,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2968
"The Directive" <th***********@ hotmail.com> wrote in message
news:84******** *************** ***@posting.goo gle.com
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.par adox.net.au...
"The Directive" <th***********@ hotmail.com> wrote in message
news:84******** *************** ***@posting.goo gle.com
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*****@clawsh rimp.com> wrote in message
news:ss******** ************@ne ws02.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.softintegra tion.com/solution/embedded/
http://www.softintegra tion.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
1897
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 24-28, 200) Organization committee: Roel Wuyts (primary contact - roel.wuyts@ulb.ac.be), Gilad Bracha, Wolfgang De Meuter, Stéphane Ducasse and Oscar Nierstrasz.
11
1889
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 enable programs to change their structure as they run." I wonder if this definition is correct. Can we define dynamic languages this way?
4
4439
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 reuse for various template parameters. I wonder if there exist techniques for achieving a dynamic polymorphism using the generic programming. Is this possible? If yes, can anyone show me simple examples in C++
6
8217
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 allocation to create object of that class ? 2. If it says "dynamic memory allocation", is it mean the following code : DestinationAddress* dest = new DestinationAddress(); // code 1
0
2077
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab, System and Software Engineering Lab), ULB (deComp) and the Belgian Association for Dynamic Languages (BADL) are very pleased to invite you to a whole day of presentations about the programming languages Self, Smalltalk and Common Lisp by experts in...
0
1227
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
4317
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 realized the market was moving into Java) and I'm trying to reimplement in Java what I did back in those days. The problem I have is that I have a job offer for programming in C++, again!!!, and I don't know if I should take it. My problem is...
1
4429
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 make program in Dynamic hashing i have to store int value in nodes user only enter int value by this value i have to find hash key and make symbol table my struct are
0
9926
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, 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...
1
10814
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,...
0
9552
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, 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...
0
7109
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();...
0
5781
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4597
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
2
4196
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.