3 ms·
Off the top of my head, Generic Functions have these features: 1. Dynamic Dispatch 2. Multiple Dispatch 3. Auxiliary Methods 4. Namespace independent of spe
by aidenn0 4y ago
Off the top of my head, Generic Functions have these features:
1. Dynamic Dispatch
2. Multiple Dispatch
3. Auxiliary Methods
4. Namespace independent of specialization parameter(s)
I find it interesting that you focus on #4. People coming to Lisp complain about #4 a lot, and people leaving lisp complain about the lack of #4. If you aren't going to use multiple dispatch (which, empirically is rare in CL code), then #4 seems to be more a matter of what one is used to. Heck, when I program in a Lisp-1, I struggle with the semantic overhead of avoiding accidentally binding a variable that happens to be the name of a function.
Also, the fact that many Lispers end up writing GFs named things like widget-frobnicate and sprocket-frobnicate might indicate that coupling the namespace with the primary operand might not be completely unwanted.
Also, Python is almost certainly the worst offender with consistency here -- e.g. "len(x)" vs "x.len()".
P.S. C++, Javascript, and Python have libraries available implementing multiple dispatch.
- lisper 4y ago> many Lispers end up writing GFs named things like widget-frobnicate and sprocket-frobnicate If they do that, they're doing it wrong. Probably because they are bringing in ideas from the non-Lisp world, not realizing that these techniques are not actually good programming practice, they are strategies for dealing with deficiencies in mainstream languages. IMHO languages should be made to serve programmers. Programmers should not have to work to serve the language. So if I want to frobnicate something I want to be able to write (frobnicate the-thing) and have it Just Work. Common Lisp gives me that (when it's is used properly). No other language does. > when I program in a Lisp-1, I struggle with the semantic overhead of avoiding accidentally binding a variable that happens to be the name of a function Yes, that is why Lisp-2 is the Right Answer.