shirok / Gauche

Scheme Scripting Engine
https://practical-scheme.net/gauche
Other
813 stars 81 forks source link

Inconsistent behavior of the default comparison routine #1074

Open shirok opened 2 weeks ago

shirok commented 2 weeks ago

Comparing classes sometimes work:

gosh> (compare <integer> <string>)
-1

But sometimes not:

gosh> (compare <integer> <real>)
*** ERROR: Object #<class <integer>> and #<class <real>> are not comparable
shirok commented 2 weeks ago

This has to do the fact that metaclass hierarchy. When (class-of x) and (class-of y) has a subtype relationship, compare calls the superclass's built-in compare callback. Otherwise, it uses the fallback code.