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]

(eq? sym1 sym2) implementation


I am wondering if the eq? operator should be implemented for symbols as follows

  sym1 == sym2 ? true : (sym1.intern() == sym2.intern());
 
The reason is, I use the DOM parser and get the value of an attribute
which is returned from java as a java.lang.String which in kawa is a
symbol. So, now when I write code like

   (case attribute-value
      ('val1 ...)
      ('val2 ...)
      (else ...))

This didn't work and was always  evaluating to the else part. After a
bit of investigation, I changed my (attribute-get node name) to
explicitly intern and return the attribute value and then it started
working as expected.

Given that two symbols if they are the same (no matter whether they
are hardcoded literals in the java code in which case they always
resolve to the same object or read through a file and hence a
different string object but captures the same string value) should
always return #t for eq? , would the above way of implementing eq? for
symbols a good idea as it removes the burden on the developer to
explicitly do the intern (which is error prone)?


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