Andrei Alexandrescu wrote:
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.)
How are the situations 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.
Then what's your problem with using Variant?
Andrei