[armedbear-devel] Using Java variable arguments

Blake McBride blake at mcbride.name
Sun Jan 24 02:31:46 UTC 2010


Java has had support for variable argument methods since version 5.
 Wouldn't it be cleaner to use that?  For example, in LispObject.java there
are several "execute" methods, one to support various numbers of arguments.
 In Java 5+ you could write:

public LispObject execute(LispObject ... arg)  {  whatever  }

You call it like you do now, i.e.  execute(a, b, c, d)

but arg gets an array of the arguments.

This way you could create one method that would handle virtually any number
of arguments in one clean method.

I'm sure this technique can be used in more places too.

Blake McBride
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20100123/aa6bfcfc/attachment.html>


More information about the armedbear-devel mailing list