New in C#4
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Thu Oct 30 04:39:29 PDT 2008
bearophile wrote:
> Julio César Carrascal Urquijo:
>> Actually Boo supported the same thing before them. Their IQuakFoo interface
>> it's the equivalent of the IDinamicObject interface in C# 4.
>
> When the LDC compiler works well (based on LLVM) I think the underlying VM may be used in ways similar to the dotnet VM or the JavaVM, so you can even think about putting in the D language more reflection, some native forms of dynamic generation and compilation of code, that today are possible in C#, macros like ones in Boo, etc.
This seems to be a common misconception.
LLVM doesn't actually have a VM in the traditional sense. It provides a
virtual instruction set, but there's no common abstractions other than
basic types (integers, floats), vectors of them, structs, static arrays,
pointers, functions and global variables (I hope I didn't miss
anything). Anything else has to be synthesized from those elements by
whatever compiler frontend (or hand-coder -- not recommended) generates
the instructions.
For example: there are no "virtual functions" in LLVM. There's just
structs whose first member happens to be a pointer to a global constant
array (or struct) of function pointers that can take a pointer to the
struct as their first argument.
In other words: every language compiling to LLVM translates its
high-level abstractions into those low-level types. And every one of
them probably does it in a slightly different way.
It's more like a sort of typed, somewhat-platform-independent assembly
designed for ease of optimization.
It's usually compiled to native code, so LLVM typically isn't even
loaded into memory at the time your code is running. There's an
interpreter and a JIT, but neither of these expose any kind of
reflection API usable by the program they're running.
LLVM is being used to _implement_ a dotnet and Java VM, but it's not
much like such a VM in itself.
More information about the Digitalmars-d
mailing list