Objective-D, reflective programming, dynamic typing

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Apr 3 09:40:45 PDT 2009


grauzone wrote:
> Andrei Alexandrescu wrote:
>> void fun(...)
>> {
>>     ... use void* _argptr and TypeInfo[] _arguments ...
>> }
>>
>> I'll ignore the fact that binding the arguments to magic, predefined 
>> names has the elegance of a fart interrupting a solemn moment. The 
>> larger problem is the type of _argptr.
> 
> That surprises me. Your string mixin callbacks (or whatever is the 
> correct name for this idiom) in std.algorithm also use magic, predefined 
> names like "a".

The situations are different. (The "$" in array index is also different.)

>> 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.


Andrei



More information about the Digitalmars-d mailing list