Objective-D, reflective programming, dynamic typing
Christopher Wright
dhasenan at gmail.com
Fri Apr 3 13:37:16 PDT 2009
Andrei Alexandrescu wrote:
>>> No safety can be built into a function that traffics in void*, EVER.
>>> No matter what you do. A proverb goes "No matter how nicely you dress
>>> a mule, you'll still call it a mule." (It was s/mule/ass/g in
>>> Romanian, but ass is ambiguous in English.) So yes, it would be a
>>> waste of time to embellish a fundamentally deeply unsafe feature. A
>>> better use of time would be to improve its safe counterpart.
>>
>> The void* is paired with a TypeInfo. A Variant uses raw data and
>> TypeInfo, and manages to be reasonably safe. If you want guaranteed
>> safety, you must use something like Java (or SafeD vaporware).
>
> I don't want guaranteed safety. I want safety when lack thereof is
> gratuitous.
But your variadic template prohibits polymorphism. Therefore, the lack
of safety with variadic arguments is not gratuitous, merely unnecessary
in certain situations.
It would, however, be quite nice to get a void*[] rather than a void*,
since it would provide more safety (array bounds) and ease of use (you
can index it or foreach it), while eliminating a standard library module.
More information about the Digitalmars-d
mailing list