This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: case behaviour


Charles Duffy wrote:
I'm somewhat confused at the behaviour of case in kawa. Might someone be
so kind as to explain the following behaviour, and perhaps suggest a
workaround?

(let ((foo (as <string> "quux")))
  (case foo (("quux") "good")
            (else "bad")))
=> good

(let ((foo (make <string> "quux")))
  (case foo (("quux") "good")
            (else "bad")))
=> bad
The case conditional uses eqv? for testing, which will only be true for strings if they are the same object (eq?), not simply equivalent.

http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-7.html#%_sec_4.2.1

You could use cond with string=? or equal?, assoc, case with (interned) symbols, and no doubt a number of more ways (patterns matcher?).

(let ((foo (make-symbol "quux")))
(case foo ((quux) "good")
(else "bad")))

jim


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]