Compiler as dll
Daniel Keep
daniel.keep.lists at gmail.com
Fri Jan 30 06:35:48 PST 2009
dsimcha wrote:
> == Quote from Yigal Chripun (yigal100 at gmail.com)'s article
>> 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.
>> 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.
>
> Out of curiosity, does anyone actually use Variant in D? When I was new to the
> language, I thought it was a great idea, but then I discovered D templates, so now
> I never use it.
The only case where I've really used it* was, not coincidentally, the
reason I wrote it in the first place: a generalised CVar system for a
game engine.
Really, you can pretty easily get away with never needing it. If you
want runtime polymorphism and you're only storing class instances, then
you can just use Object instead. Variant is really only useful if you
want to store non-class types as well without having to Box them, or you
really want value semantics.
Still, it's cool that it works as well as it does... :D
-- Daniel
* I'm referring to Tango's Variant, not Phobos'.
More information about the Digitalmars-d
mailing list