Jump to content

class creation during run-time

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
vernes

vernes

    Newbie

  • Members
  • Pip
  • 8 posts

Question

I wish to know what techniques are available for generating classes during run-time.
Examples need not be language specific, but it has to be a language in which you'd expect graphic-intensive applications to be build in. (so no php example)

Explaination

I hope to use it for a simulation involving huge numbers of objects which can combine during the course of the simulation and form cluster-objects.
The cluster-objects will have properties and behaviours based on the properties and behaviours of the sub-objects.
To keep the simulation running smoothly, the cluster-objects will be used to create new classes from which identical combinations will be instanced from.

The thought behind this is whenever two cluster-objects interact, the result can be calculated faster because you do not need to itterate through all the sub-objects but instead check the generalized properties of the cluster-object.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
As long as you are talking about creating pre-defined objects on the fly, it's simply a matter of using pointers/references based on the languages properties. This is the same mechanism used to create linked lists, etc.

If you are talking about defining and then creating the objects, you will basicly need a "generic" class that will have a very limited number of options. In C++ this might be a vector of unions with a parallel vector of type indicators and a few set/get routines for grabbing a value correctly out of the vector.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
G_Morgan

G_Morgan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 537 posts
Lisp could easily do this (assuming you are talking about defining new classes rather than objects) but it isn't generally used for graphical applications.

I think you definitely need to look towards functional programming if you are talking about run time class definition. Imperative programming is far too static. Maybe OCaml will suit your purposes since it is designed as an object oriented functional language. No functional language is used a great deal in industry though, the sheer dynamism of them takes a lot of learning and most corporations won't bother training people to handle them when there are so many imperative language developers out there already (after all they are all turing complete, what does it matter if you need an order of magnitude more code).

#4
vernes

vernes

    Newbie

  • Members
  • Pip
  • 8 posts
I found this discussion somewhere else.
Dynamic class creation at runtime
Seems to be what I'm looking for.

What do you think?