On Thu, Dec 15, 2011 at 8:05 PM, Softaddicts
<lprefonta...@softaddicts.ca> wrote:
> From a JVM perspective, f(& arglist) is a one arg function.
> Try defining a fn with more than 20 args and you will get the
> "can't specify more than 20 arguments...." error.
> This is the maximum supported by the Clojure runtime for "non-optimized" fns.

Well, that's just silly, since a simple change to the fn macro would
make that go away without any hassle, as I already outlined. (The
error would remain for direct users of fn*, of course.)

> One can argue about the argument size limit of optimized fn calls. Maybe 4 is 
> too low.
> These limitations has David pointed out are indirectly inherited from the JVM 
> architecture.

As I understand it, the problem is a combinatorial explosion of
interfaces with various signatures. Which is only a problem because,
for some reason, static calls to optimized fns are not made directly
to the fn's class. Why not just make an optimized fn class look like

public class MangledName implements IFn {
    public Object invoke () { // unoptimized zero-arg version or arity
throw goes here }
    public Object invoke (Object x) { // unoptimized one-arg version ... }
    ...
    public static long optimized (int bar, double quux, Object
fiddlefaddle, long x, long y, long z) {
        // optimized version goes here
    }
}

and an optimized call site produce the same bytecode as

MangledName.optimized(a, b, c, d, e, f);

with possible unboxing of some of the arguments, and possible boxing
of the return value, depending on the context. An unoptimized call
site would use the IFn interface and behave exactly as now or under
Clojure 1.2.

> There are multiple ways to work around this limit. Destructuring, passing a 
> map, ...

All of those box any primitives as part of wrapping them in collections.

-- 
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

Reply via email to