Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-dev] Re: idea for refactoring

>Gregg G. Wonderly wrote:
>>>Nope :)
>>>varargs  are also useful.
>>>But sometimes like Dan said you have something like this:
>> 
>> 
>> For trailing optional arguments, varargs will provide a mechanism.  However,
  
>> the general case won't work with varargs.  I, personally, think this adds 
>> confusion to the reader of the code.  APIs like JOptionPane have continuousl
 y 
>> been frustrating because there are too many overrides, some with more than 3
  
>> arguments which is the jumpoff point for my eye and brain coordination.
>
>Well, python offers a clean solution:
>
>     def func (a, b, c=1, d=[], *args, **kw):
>         ...

But, in this case, the following starts to get a bit ugly.

	func( 1, 2, d=3, d, d=3 )

is the first 'd=3' an assignment to 'd', or adding '3' to the list of 
parameter element 'd'?  This is where you have to be a little more careful of 
how convenient you think you are making your argument list...

-----
gregg@xxxxxxxxxxxx  (Cyte Technologies Inc)




Back to the top