On Friday, July 18, 2014 4:01:10 PM UTC-7, Stefan Karpinski wrote: > If Julia has shown anything, it's that you *can* have ubiquitous multiple > dispatch in a dynamic language and have it be very fast – it is commonly a > zero-cost abstraction in Julia. >
I find this an interesting claim. Do you have some easy, high level pointers to what ideas are used to get to zero-cost? (I realize you have a "commonly" disclaimer here, so perhaps I'm hoping for too much). Consider the following example: F(a,b,c) I could see how one can dispatch *very* quickly based on exact types: make a hash of ("F",type(a),type(b),type(c)) and look up in a hash-table. Other than the increased cost of creating the hash key, the work required here is about the same as what python has to do every time anyway (look up the binding of "F" which, depending on the context, may just be as bad as doing a hash table lookup) However, dispatch on exact types is virtually useless in a setting that uses inheritance to any significant degree. You need to take inheritance into account for type dispatch. That means that signature lookup has to happen with respect to a partial ordering: We want the most specific signature that generalizes the types of the arguments--if that's not unique we have an ambiguity. It seems to me the complexity of this will always depend on the relevant part of the type inheritance tree. How do you get from there to zero cost, or at least cost independent of the complexity of the type tree? By hoping that type inference gets you down to a small enough corner of the type tree? -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.