Again thanks a lot for your patience and help. My problem was that I thought the literal "1" will be boxed behind the scenes, I didn't even bother looking for a version of "add" for primitives because I thought they never existed in Clojure.
I'll try to go over the Numbers class again and see if all this makes sense. - John On Apr 20, 8:10 am, Per Vognsen <[email protected]> wrote: > On Tue, Apr 20, 2010 at 7:02 PM, Per Vognsen <[email protected]> wrote: > > With the way primitive types are currently supported in the compiler, > > if you wanted it to work the way you expect, you'd need to express the > > complicated arithmetic tower and its grid of type conversions in a > > static form accessible to the compiler. It seems like it would be a > > good amount of work. You can file a feature request for it if you > > want. > > Actually, a less elegant, more brute force way would be to add method > implementations for all operand type combinations. For example, you'd > have > > static public long add(long x, int y){ > return add(x, (long) y); > > } > > static public long add(int x, long y){ > return add((long) x, y); > > } > > and so on. > > Unfortunately, there are a whole lot of combinations if you want to > cover the whole arithmetic tower. The issue is that the current > primitive type support relies directly on Java's type system, so you > cannot abstractly express the pattern underlying the arithmetic tower > like you might in some languages with type-level functions. > > -Per > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group > athttp://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 [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
