[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] [r6rs-discuss] redefining eqv?



On Fri, 24 Dec 2010, Peter Kourzanov wrote:

  > On Fri, 2010-12-24 at 20:49 +0900, Adrien "Pied" Piérard wrote:
  > And now comes a question from a user who reads all your debates in
  > awe, but can't help thinking there's a lot of hair splitting involved.
  >
  > "Why not just parameterize CASE or whatever pattern-matcher with an
  > equivalence predicate?"
  >
  > Wouldn't this solve many problems we read here?
  > Would it create enough others problems to be disqualified?
  >
  > I believe that
  >
  > (case-with my-equality-predicate foo
  >  ((bar) quux)
  >  (else rofl)))

  That's what I always do in my own code, which could be fine for a
  semi-advanced user that redefines (case) for fun. The problem is that
  the core language will lose its terseness appeal to newbies and veterans
  if you proceed this way... And Eli will be unhappy if he accidentally
  imports "wrong" (case) macro.

  P.S. Note that both Haskell and Scala have special devices to attack
  this problem (typeclasses resp. mixins). Not sure what ML is doing, but
  OCaml could solve this with its OO system supposedly too.

I think one of the principal ways CASE was originally intended to be used
was for fast dispatch on symbols or possibly numbers used as typetags in
objects represented as lists, e.g.,

  (case (car object)
    ((node) .....)
    ((leaf) .....))

I believe there are some Schemes, like STALIN, that highly optimize such
CASE expressions.  This would be harder to do in a higher-order CASE.

Andre
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports