guile-user
[Top][All Lists]
Advanced

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

Re: Bug in and-map and or-map? What am I doing wrong?


From: Keith Wright
Subject: Re: Bug in and-map and or-map? What am I doing wrong?
Date: Fri, 11 May 2001 13:34:41 -0400

> From: Martin Grabmueller <address@hidden>

> Hmmm, according to R5RS, `eq?' expects _exactly_ two arguments, and
> `=' expects two or more arguments ...
> 
> Actually, yesterday I was quite annoyed because I had a hard-to-find
> bug in one of my Scheme programs.  I somehow found out that I had
> forgotten to supply the second argument to `char=' in several places.
> This error would immediatly have caused an exception, if the
> comparison procedures in Guile would behave in R5RS manner.  _All_
> Guile comparison procedures have this problem (char{=,<,>,<=,>=}?,
> string{=,<,>,<=,>=}?...)

Well, to complete the picture of confusion, all those procedures
are specifed to take two arguments, but the generalization to more
than two arguments is explicitly mentioned, one might almost say
recommended---or is it just warning Martin not to get tricked?

The only reason I can think of for this inconsistency is that
the generalisation of equality to more arguments is a (long) one liner:

(lambda xs (not (memq #f (map (lambda (x) (eq? (car xs) x)) (cdr xs)))))

while properly extending inequality is more work.

The generalization to fewer than two arguments is not mentioned
for any of them.  It's obvious to me that (<) is #t, but I wouldn't
be surprised if someone thought otherwise.

I'm not enthusiastic about "fixing" this by removing the
generalization, but if someone does take it upon themselves
to chop out working code, think about removing the zero and
maybe the one argument cases and letting us still have

(define (hex c) (char<=? #\A c #\F))

I would leave it alone.  Guile has never been afraid to
extend R5RS.  It has gone too far in worse ways than this.
-- 
     -- Keith Wright  <address@hidden>

Programmer in Chief, Free Computer Shop <http://www.free-comp-shop.com>
         ---  Food, Shelter, Source code.  ---



reply via email to

[Prev in Thread] Current Thread [Next in Thread]