On Dec 8, 2008, at 2:05 PM, Randall R Schulz wrote:

Correct me if I'm wrong or insufficiently aware of the relevant issues,
but is it not the case that such a helper function has an easier job
for Format since it wants an array of Object. In other contexts, you
have to know what the type of the array elements are to construct an
acceptable varargs array.

I was addressing "format" itself. In the case of any (manually written) Clojure wrapper for a Java variadic method, you would know the required type and could ensure it using:

        (into-array the-type args).

So would it not be the case that to be generic a varargs array-builder
would have to use reflection on the target method?

Reflection to determine the array type seems necessary to accomplish that.

Another issue is how to distinguish a single argument at the varargs position between:

        an array being passed as a single varargs argument itself, and
        an array being passed containing the varargs arguments.

Java looks for a type match to the array type that corresponds to the varargs param type (e.g., Foo... -> Foo[]) to distinguish. I think Clojure could do the same.

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to