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

Re: [Scheme-reports] match.scm



Peter Kourzanov <peter.kourzanov@x> 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@x

Attachment: pgpQcAHNpN74O.pgp
Description: PGP signature

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