I found this (mis)feature quite annoying too. I think, we all shall ask the language authors to fix it.
On Tuesday, December 11, 2012 10:44:34 AM UTC+4, Andy Fingerhut wrote: > > You can pass in a length 0 array of > java.nio.file.attribute.FileAttribute's like so: > > (java.nio.file.Files/createTempDirectory "mytempname" (make-array > java.nio.file.attribute.FileAttribute 0)) > > Andy > > > On Dec 10, 2012, at 8:54 PM, Dave Kincaid wrote: > > I just came across this same problem while trying to use Java 7's > java.nio.file.Files.createTempDirectory() > (http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#createTempDirectory(java.lang.String, > > java.nio.file.attribute.FileAttribute...)) > > Clojure won't let me just do (java.nio.file.Files/createTempDirectory > "mydir") > > It wants the FileAttribute argument. Can anyone help me get past this? I'm > stuck since I really can't figure out how to create a FileAttribute. Am I > better off just using Apache commons or something like that? > > On Monday, September 27, 2010 7:20:04 PM UTC-5, ataggart wrote: >> >> The vararg at the end of the method is just syntactic sugar for an >> array, so the "add" method actually takes 4 args, the last being a >> Resource array. The java compiler just replaces "missing" varargs >> with an empty array. >> >> My guess is that the reflection mechanisms in the compiler just look >> at type/arity. The Method object has a isVarArg() boolean, so that >> could be used to allow omitting varargs altogether. That would need >> to be an enhancement to the clojure compiler, so I opened a ticket: >> >> >> https://www.assembla.com/spaces/clojure/tickets/440-java-method-calls-cannot-omit-varargs >> >> >> >> On Sep 27, 1:16 pm, JonathanBelolo <jonat...@scorpiomusic.fr> wrote: >> > While toying with the Sesame2.3 library, I've come across the >> > following behavior for the first time. >> > >> > This is taken from the api doc for >> > org.openrdf.repository.base.RepositoryConnectionBase: >> > >> > add(Resource subject, URI predicate, Value object, Resource... >> > contexts) >> > Adds a statement with the specified subject, predicate and >> > object to this repository, optionally to one or more named contexts. >> > >> > But apparently, Clojure seems to think the optional args are >> > mandatory... >> > >> > (.add con alice RDF/TYPE person) >> > >> > No matching method found: add for class >> > org.openrdf.repository.sail.SailRepositoryConnection >> > [Thrown class java.lang.IllegalArgumentException] >> > >> > So I run >> > >> > (grep #".add" (.getMethods (.getClass con))) >> > >> > #<Method public void >> > >> org.openrdf.repository.base.RepositoryConnectionBase.add(org.openrdf.model. >> Resource,org.openrdf.model.URI,org.openrdf.model.Value, >> org.openrdf.model.Re source[]) >> > throws org.openrdf.repository.RepositoryException>) >> > >> > Finally the following works... >> > >> > (.add con alice RDF/TYPE person (make-array Resource 1)) >> > nil >> > >> > Is this behavior normal? Are optional args mandatory when called with >> > interop? >> > >> > Thanks for your help :) >> > >> > Jonathan > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clo...@googlegroups.com <javascript:> > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+u...@googlegroups.com <javascript:> > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en