bug-guile
[Top][All Lists]
Advanced

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

Report: `case' does not conform to R5RS + fix


From: Martin Grabmueller
Subject: Report: `case' does not conform to R5RS + fix
Date: Wed, 17 Jan 2001 16:01:35 +0100

Hello,

`case' as currently implemented in Guile does not conform to R5RS,
because it allows an `else'-clause in any position in the clause list.

R5RS (section 4.2.1) states: [...] The last <clause> may be an ``else
clause'', which has the form [...]

Guile allows the following code, which evaluates to 'consonant

(define a 'w)

(case a
  ((a e i o u) 'vowel)
  (else 'consonant)
  ((y w) 'semi-vowel))

The correct version would be:

(case a
  ((a e i o u) 'vowel)
  ((y w) 'semi-vowel)
  (else 'consonant))

The patch attached below rejects the first `case' statement and allows
only the second one.

If you think this bug report is too picky, please tell me and ignore
this post.

Thx,
  'mgrabmue
-- 
Martin Grabmueller              address@hidden
http://www.pintus.de/mgrabmue/  address@hidden on EFnet

===File ~/cvs/guile-core/diff===============================
Index: libguile/eval.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/eval.c,v
retrieving revision 1.188
diff -c -r1.188 eval.c
*** libguile/eval.c     2000/12/28 16:49:09     1.188
--- libguile/eval.c     2001/01/17 14:57:06
***************
*** 595,601 ****
        proc = SCM_CAR (x);
        SCM_ASSYNT (scm_ilength (proc) >= 2, xorig, scm_s_clauses, s_case);
        SCM_ASSYNT (scm_ilength (SCM_CAR (proc)) >= 0
!                 || SCM_EQ_P (scm_sym_else, SCM_CAR (proc)),
                  xorig, scm_s_clauses, s_case);
      }
    return scm_cons (SCM_IM_CASE, cdrx);
--- 595,602 ----
        proc = SCM_CAR (x);
        SCM_ASSYNT (scm_ilength (proc) >= 2, xorig, scm_s_clauses, s_case);
        SCM_ASSYNT (scm_ilength (SCM_CAR (proc)) >= 0
!                 || (SCM_EQ_P (scm_sym_else, SCM_CAR (proc)) 
!                     && SCM_NULLP (SCM_CDR (x))),
                  xorig, scm_s_clauses, s_case);
      }
    return scm_cons (SCM_IM_CASE, cdrx);
============================================================



reply via email to

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