January 05, 2008
"0ffh" <frank@youknow.what.todo.interNETz> wrote in message news:flmmgh$24hb$1@digitalmars.com...

>
> I know people will hate me for this, but IMHO the problem with variadic
> args is not a lack of sophistication, but an abundance of the same.
> In C it works because C tries to be simple and straightforward (from a
> machine pov, not necessarily from a human one), while the additional
> sophistry that D introduced stands in the way of a simple solution.
> The simplest way to fix this would probably be to give up the array
> of the _arguments. But as in these times it is practically unthinkable
> (and also, I admit, not really desirable) to live without the type
> information they provide, the only way out I can see is to add yet more
> complexity to the D compiler to handle this as a special case.
>
> Anyways, I don't think this is really a big issue. It's just a bit of a surprise for those of us who are used to a simpler paradigm.

What would make most sense to me would be if there were a built-in variant type, or maybe a library-provided (library-extended?) variant type.  Then variadic functions just become a flavor of typesafe varidic functions with some implicit casting to Variant.  Then you can mess around with the array of args, change the values, change the size of the array, save it somewhere, pass it along, pass a slice along etc.


January 05, 2008
Jarrett Billingsley wrote:
> "0ffh" <frank@youknow.what.todo.interNETz> wrote in message news:flmmgh$24hb$1@digitalmars.com...
> 
>> [...]
>> Anyways, I don't think this is really a big issue. It's just a bit of a
>> surprise for those of us who are used to a simpler paradigm.
> 
> What would make most sense to me would be if there were a built-in variant type, or maybe a library-provided (library-extended?) variant type.  Then variadic functions just become a flavor of typesafe varidic functions with some implicit casting to Variant.  Then you can mess around with the array of args, change the values, change the size of the array, save it somewhere, pass it along, pass a slice along etc. 

Right, there's that one solution, the array of variants where all the rest
goes. But I can do that now already, just with a different syntax than the
ellipsis. And just thinking of the runtime cost makes me dizzy, but that's
a personal thing. Probably comes from doing too much coding on 24MHz 16bit
machines. =)

regards, frank
January 09, 2008
Jarrett Billingsley wrote:
> Actually, passing _argptr in C probably wouldn't work either, at least not portably. 

Just for the record: Right, I misremembered! Awkward! :-(

I went back to my archives and found two solutions I used, one compiler-
specific and one an ugly hack involving macros like: "#define va_pass_4 *(int*)args,((int*)args)[1],((int*)args)[2],((int*)args)[3]".

regards, frank (blushing)

1 2
Next ›   Last »