I found it painful to do object-oriented programming in Common Lisp. The main problem is the naming of methods.Please see the code below.
(defclass foo () ())
(defmethod action ((object foo))
(write-line "hello"))
(defclass bar () ())
(defmethod action ((object bar) boo)
t)
(print
(action (make-instance 'foo)))
(print
(action (make-instance 'bar) 1))
The two action methods are not different implementations for a same generic function. They have the same name by accident.
But Common Lisp requires all methods with the same name to have the same numbers of parameters.
In order to avoid the name conflicts, I usually prefix the methods' names with the class names, such as foo-action and bar-action. But that causes the code to be quite verbose in real program, e.g. (lengthy-class-name-do-something some-variable).
Other object-oriented programming languages, like C++ and Java, do not have such problems. You can write that like some_variable.do_something() with no name conflicts in them.
So I'd like to know if there exists any better solution to the problem described above?