Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1. You say that I "avoid the macro". Why is avoiding macros an advantage? 2. Your answer solves the very specific case in my example. With more functions and more dispatch options your would need something like case which would add some overhead to the code Commented Mar 10, 2015 at 11:42
  • 1. Macros have a number of disadvantages over functions. They are not first-class values, they don't exist at run-time, and cannot be passed around - you cannot use a macro with map or reduce, for instance. They are harder to test, and hard to get right. The general rule is only to use macros when you have to - when you want to avoid evaluating arguments, and for making new control structures/syntax. Commented Mar 10, 2015 at 11:58
  • 2. And yes, but instead it's dynamic, which is the point of dynamic dispatch - it's not set at compile time. How you actually implement the dispatch function depends on your underlying logic. If your main goal is performance I would not use multi-methods to being with. Commented Mar 10, 2015 at 12:01