Compiler as dll
grauzone
none at example.net
Fri Jan 30 05:06:46 PST 2009
Yigal Chripun wrote:
> Static languages can have Variant/box types that'll give most of the
> same functionality of dynamic languages. so, instead of instantiating
> list!(int), list!(string), etc, you can get one list!(Variant)..
> C# provide such a feature with a keyword instead of rellying on templates.
It would be nice if D would be extended to provide all these things. I
guess the only reason this hasn't been done is the space overhead of
full RTTI information. (And dynamic method invocation might require a
lot of hackery to manually copy the method arguments on the stack.)
> The real difference is that static languages have mostly read-only RTTI.
> (Java provides a very limited capability to reload classes, IIRC)
> a scripting language allows you to manipulate Types and instances at
> run-time, for example you can add/remove/alter methods in a class and
> affect all instances of that class, or alter a specific instance of a
> class. This cannot be done in a static language.
Some static languages allow it to statically add your own methods or
variables to a foreign class. An example would be AspectJ, which, among
other things, adds this feature to Java.
This is still not as dynamic as in dynamic type systems, but I wonder if
you really need more?
There's something similar in current static languages: you can extend
the global data segment with global variables. Global variables don't
have to be all in a single source file. Instead, the linker takes care
of collecting global variables from object files and allocating space
for them in the data segment. A dynamic linker can do this even while a
program is running!
Thread local storage (with global __thread variables) does the same
thing per thread. Threads can be created and destroyed at runtime.
Dynamic linking is still supported, I think.
More information about the Digitalmars-d
mailing list