www.digitalmars.com         C & C++   DMDScript  

D - strict varargs

reply "Pavel Minayev" <evilone omen.ru> writes:
How about a syntax to define a function that takes an unlimited number
of arguments of _one_, strictly defined type? Something like this:

    void printfi(int count, int...);    // takes unlimited number of ints
    void printfs(int count, char[]...); // takes unlimited number of strings
Feb 04 2002
parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
That would not be far from simply taking a dynamic array of those types.  That
can already be done; question is, it it worth having the compiler do it for you?

Pavel Minayev wrote:

 How about a syntax to define a function that takes an unlimited number
 of arguments of _one_, strictly defined type? Something like this:

     void printfi(int count, int...);    // takes unlimited number of ints
     void printfs(int count, char[]...); // takes unlimited number of strings
-- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]
Feb 04 2002
parent "Pavel Minayev" <evilone omen.ru> writes:
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:3C5EFE95.E9A3B0DB deming-os.org...
 That would not be far from simply taking a dynamic array of those types.
That
 can already be done; question is, it it worth having the compiler do it
for you? If we have array literals, no. It'd look like this, then: printfi([1, 2, 3]); But we don't have them and we don't know if they'll be there or not.
Feb 04 2002