On Wed, 05 Aug 2009 07:20:38 +0400, Benji Smith <dlangu...@benjismith.net>
wrote:
Frank Benoit wrote:
Andrei Alexandrescu schrieb:
Ary Borenszweig wrote:
call!(foo)(5, "hello")
with varaidic args?
Well some don't like to need to remember the order of arguments.
Andrei
Assigning the argument by name instead of order has two other benefits,
i can think of...
1. on the call side, it is documented for what the given values are
used.
2. it may be possible to let all parameters have default values and for
example just give a value for the last parameter. This is not possible
with just the parameter order.
But these aren't issues with reflection. These are just the same
function calling rules applied elsewhere in the language:
1) If you want to call a function: you must know its name.
2) If you want to pass parameters: you must know the correct order.
I can't imagine a circumstance where someone uses reflection to call a
function and knows how to create the correct set of arguments, but
doesn't know what order to put them in.
--benji
They are mostly used with optional parameters:
void foo(int x = -1, int y = 42, bool b = false);
foo(b: true);