On Friday, August 1, 2014 5:32:15 PM UTC+8, Tassilo Horn wrote: > > Flea Wong <[email protected] <javascript:>> writes: > > Hi! > > I'll take the third question first: > > > 3. Why the different function call "subtotal" (*without* Dot, see > > Apple) vs ".subtotal" (*with* Dot, see Orange) for extend-type vs > > inline implementation of Fruit? > > You should always use (subtotal fruit). That with an inline > implementation which is backed by some generated interface there is a > .subtotal method is a pure implementation detail you shouldn't rely on. > I.e., (.subtotal fruit) is no function call but a Java interop method > call.
Ok. Guess it make sense. But it seems rather inconsistent to me. > > 1. Why *doesn't* extend-type (see Banana) work when implementing > > protocol Fruit in a different namespace > It does work, but since Banana doesn't extend Fruit inline, the > corresponding Fruit interface has no .subtotal method, so you cannot > call it using (.subtotal banana) but (subtotal banana) will work. > > I've tried (subtotal (Banana 2)) - as you've suggested (without '.') i get compile error: Unable to resolve symbol: subtotal in this context. So in it doesn't work. I don't understand how you got it to work. AFAIK, extend-type across ns does not work - with or without the '.'. > > 2. Why *does* inline implementation (see Apple) work when > > implementing protocol Fruit in a different namespace > > Calling (.subtotal apple) works, because it's implemented inline and so > the corresponding interface has that method and you can call it using > Java interop which (.subtotal apple) is. Ok. > > Bye, > Tassilo > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
