Re: Protocols/multimethods vs core.match
core.match compiles down to case, does it not? So the comparisons here are similar: http://insideclojure.org/2015/04/27/poly-perf/ -- Morgon On Friday, May 15, 2015 at 2:57:23 PM UTC-4, tbc++ wrote: One big thing to consider is that core.match is closed dispatch. If you write a function that uses core.match, I can't extend it inside my code. This is something that is possible with both multi-methods and protocols. Timothy On Fri, May 15, 2015 at 12:49 PM, Sam Raker sam@gmail.com javascript: wrote: The discussion/post-linked-to in https://groups.google.com/d/msg/clojure/eoAp6QVimYI/iipmEJNKdrIJ have got me thinking about protocols multimethods, which I admittedly have possibly never actually used, now that I think about it. I'm wondering how they differ from core.match[1]. I realize protocols, specifically, have a niche for when you have concrete type information about your data and want better performance. I'm a little less clear about multimethods--in particular, I just considered using multimethods for something, and then ended up reaching for core.match because it seemed more closure-friendly. What, if any, are the benefits of using protocols/multimethods over core.match, or vice versa? When would you reach for one and definitely not the other(s)? [1] https://github.com/clojure/core.match -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: 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 clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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 --- 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Protocols/multimethods vs core.match
No, it actually compiles down to a pile of ifs, and try/catch/throws (for backtracking). It's pretty fast, but it won't be as fast as a jump table for complex matches, that's for sure. Timothy On Fri, May 15, 2015 at 5:53 PM, Surgo morgon.kan...@gmail.com wrote: core.match compiles down to case, does it not? So the comparisons here are similar: http://insideclojure.org/2015/04/27/poly-perf/ -- Morgon On Friday, May 15, 2015 at 2:57:23 PM UTC-4, tbc++ wrote: One big thing to consider is that core.match is closed dispatch. If you write a function that uses core.match, I can't extend it inside my code. This is something that is possible with both multi-methods and protocols. Timothy On Fri, May 15, 2015 at 12:49 PM, Sam Raker sam@gmail.com wrote: The discussion/post-linked-to in https://groups.google.com/d/msg/clojure/eoAp6QVimYI/iipmEJNKdrIJ have got me thinking about protocols multimethods, which I admittedly have possibly never actually used, now that I think about it. I'm wondering how they differ from core.match[1]. I realize protocols, specifically, have a niche for when you have concrete type information about your data and want better performance. I'm a little less clear about multimethods--in particular, I just considered using multimethods for something, and then ended up reaching for core.match because it seemed more closure-friendly. What, if any, are the benefits of using protocols/multimethods over core.match, or vice versa? When would you reach for one and definitely not the other(s)? [1] https://github.com/clojure/core.match -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@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+u...@googlegroups.com 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 clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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 --- 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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 --- 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Protocols/multimethods vs core.match
The discussion/post-linked-to in https://groups.google.com/d/msg/clojure/eoAp6QVimYI/iipmEJNKdrIJ have got me thinking about protocols multimethods, which I admittedly have possibly never actually used, now that I think about it. I'm wondering how they differ from core.match[1]. I realize protocols, specifically, have a niche for when you have concrete type information about your data and want better performance. I'm a little less clear about multimethods--in particular, I just considered using multimethods for something, and then ended up reaching for core.match because it seemed more closure-friendly. What, if any, are the benefits of using protocols/multimethods over core.match, or vice versa? When would you reach for one and definitely not the other(s)? [1] https://github.com/clojure/core.match -- 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 --- 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Protocols/multimethods vs core.match
One big thing to consider is that core.match is closed dispatch. If you write a function that uses core.match, I can't extend it inside my code. This is something that is possible with both multi-methods and protocols. Timothy On Fri, May 15, 2015 at 12:49 PM, Sam Raker sam.ra...@gmail.com wrote: The discussion/post-linked-to in https://groups.google.com/d/msg/clojure/eoAp6QVimYI/iipmEJNKdrIJ have got me thinking about protocols multimethods, which I admittedly have possibly never actually used, now that I think about it. I'm wondering how they differ from core.match[1]. I realize protocols, specifically, have a niche for when you have concrete type information about your data and want better performance. I'm a little less clear about multimethods--in particular, I just considered using multimethods for something, and then ended up reaching for core.match because it seemed more closure-friendly. What, if any, are the benefits of using protocols/multimethods over core.match, or vice versa? When would you reach for one and definitely not the other(s)? [1] https://github.com/clojure/core.match -- 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 --- 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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 --- 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.