Objective-D, reflective programming, dynamic typing

grauzone none at example.net
Fri Apr 3 09:22:47 PDT 2009


Andrei Alexandrescu wrote:
> grauzone wrote:
>> How do I make this work with, say, interface functions?
>>
>> But I already know your reply.
> 
> I don't know it. What is it?

See your reply to Jarett. Granted, being able to have final methods in 
interfaces would improve the situation. But in general, there's no 
reason to abandon varargs, if only they weren't implemented in such a 
sucky way.

Anyway, I'll add my own proposal for improving varargs, although it's a 
waste of time:

1.) For _argptr, replace the void* by a void*[], that is indexed by the 
argument number. Currently, _argptr is a raw pointer to the stack, and 
getting a pointer to an individual argument on all platforms/compilers 
is non-trivial.

2.) Allow a way to chain function calls with varargs. Currently, if you 
have _argptr and _arguments, you can't pass them to another variadic 
function. Basically, you would have to allow passing _argptr and 
_arguments instead of real arguments to a function with ... in its 
signature.

When you combine both feature requests, it would be trivial to build 
vararg calls at runtime. You'd simple stuff the TypeInfo and the pointer 
to your data into _argptr and _arguments, and call a variadic function 
with it.

But if you don't intend to change anything about varargs, please let 
Walter kill this abortion. Fighting with the trivial, unnecessary 
restrictions of the current implementation is really annoying.

> Andrei



More information about the Digitalmars-d mailing list