Does CLOS have an eql specialization dispatch on strings?
- by mhb
Examples of what you can do.
(defmethod some-fn ((num real)) (print "an integer"))
(defmethod some-fn ((num real)) (print "a real"))
(defmethod some-fn ((num (eql 0))) (print "zero"))
(some-fn 19323923198319)
"an integer"
(some-fn 19323923198319.3)
"a real"
(some-fn 0)
"zero"
It also works with a general 'string type.
(defmethod some-fn ((num string)) (print "a string"))
(some-fn "asrt")
"a string"
Not with a specific string, however
(defmethod some-fn ((num (eql "A")) (print "a specifict string")))
=> doesn't compile
I imagine it doesn't work because eql does not work on strings in the way that would be necessary for it to work.
(eql "a" "a") => nil
Is there a way to do it?