3 ms·
My point is that this: > Most implementations of Common Lisp prevent shadowing builtin symbols. is irrelevant. It's actually irrelevant for two reasons. Fir
by lisper 6y ago
My point is that this:
> Most implementations of Common Lisp prevent shadowing builtin symbols.
is irrelevant. It's actually irrelevant for two reasons. First, the example under discussion was SQUARE which is not a CL builtin, and second, even if it was, you could just do this:
Just make your own package and do:
(in-package :my-package)
(defmethod square ((n number)) (* n n))
Now you can extend SQUARE to work on things other than numbers. Or, to pick a more realistic example:
(defmethod sqrt ((n number)) (cl:sqrt n))
- rini17 6y agoOh that's the misunderstanding, I was talking about overloading of the '*' operator and the consequent confusion, not overloading of 'square'.
- lisper 6y ago* is not an operator in Lisp. It's a function. Lisp doesn't have operators. To be more precise, cl:* is a function. But you can make a symbol named "*" in another package and define it however you like.