On Fri, May 20, 2011 at 2:24 PM, László Török <ltoro...@gmail.com> wrote: > On May 20, 2011 7:55 PM, "Fogus" <mefo...@gmail.com> wrote: >> In the alpha7 release the defrecord macro was changed to generate a >> couple of auxiliary functions (for a record R) named map->R and ->R. >> The first takes a map and returns a function of its contents. The >> second takes the same number of arguments as the record constructor. >> It's the definition of this second function that is reporting an >> error. It's easy enough to fix, but I guess the question is should it >> be fixed? That is, do people define records with 19+ fields? Does >> this pose a problem for existing code? > Hi, > > What's the incremental runtime cost of increasing the max number of fields > to 40? :-)
Oh, there's no need for that. Just add a little smarts to the constructor generating macro to detect 19+ fields and then define it as (defn ->Foo [& fields] (if (not= (count fields) whatever) (throw-arity-exception) (Foo. (nth fields 0) (nth fields 1) (nth fields 2) ...))) or maybe for efficiency use a let cascade: (let [p1 (first fields) fields (rest fields) p2 (first fields) fields (rest fields) ...] ...) Of course there's probably some JVM limit on the number of constructor args, too. I'd suggest if you have records that large to consider restructuring them to have a smaller number of fields that are more composite -- seqs, vectors, sets, maps, even nested records. Surely there's *some* structure beyond a heterogeneous assortment of twenty-plus objects? -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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