Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 4427 days ago | link | parent

"The only new drawback I learned about was that equal can't handle cycles. I hadn't thought of that. It's not hard to fix, but the obvious fix costs performance every single time."

Just as a point of interest, Racket handles this with its built-in types:

  > (define foo (mlist 1))
  > (set-mcdr! foo foo)
  > foo
  #0=(mcons 1 #0#)
  > (define bar (mlist 1 1))
  > (set-mcdr! (mcdr bar) bar)
  > bar
  #0=(mcons 1 (mcons 1 #0#))
  > (map (lambda (f) (f foo bar)) (list equal? eqv? eq?))
  '(#t #f #f)
Racket also allows 'equal? to have custom behavior for user-defined types, and the custom behavior can handle cycles too. (http://docs.racket-lang.org/reference/booleans.html#(def._((...)

I brought this up briefly at http://www.arclanguage.org/item?id=12860.