Re: [Scheme-reports] match.scm Alex Shinn (15 Dec 2010 18:25 UTC)
Re: [Scheme-reports] match.scm Peter Kourzanov (15 Dec 2010 19:33 UTC)
Re: [Scheme-reports] match.scm Jim Wise (15 Dec 2010 19:51 UTC)

Re: [Scheme-reports] match.scm Jim Wise 15 Dec 2010 19:50 UTC
Peter Kourzanov <peter.kourzanov@gmail.com> writes:

>> > * matching numbers: we need to use (=) to match them, not equal?
>> > (or eqv? and eq?)
>>
>> Do we? :)
>>
>
> Typing. A good example: 42+0.0 should match both 42.0 and 42.

Note that (R6RS) syntax-case is defined to use equal? for literal
pattern data:

  * P is a pattern datum (any nonlist, nonvector, nonsymbol datum) and F is
    equal to P in the sense of the equal? procedure.

which reduces to `=' for two exact or two inexact values, but #f
otherwise.  R6RS also notes that `=' is not required to be reliable for
inexact numbers.

The Wright pattern-matching library uses equal? for literal pattern
data, as well, as do the Racket, Chicken, and match.scm implementations.
This has the advantage of providing a single rule for literal data.

What is the use case for special-casing numbers?

--
				Jim Wise
				jwise@draga.com
_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports