Re: cond clause does not allow definitions

Jeronimo Pellegrini <[email protected]>
Newsgroups gmane.lisp.guile.user
Message-ID <[email protected]>
On 2024-05-22 18:07, Pierpaolo Bernardi wrote:
> In chez:
> 
>> (cond (else (define x 7) x))
> 7
>> x
> 7
> 
> which looks like a bug to me. You may check if x is defined outside of
> the cond expression in the other implementations which do not raise an
> error too?

Sure! And the result varies a lot!

(cond (#t (define x 7) x))
(cond (else (define y 7) y))

| System      | A     | x     | B         | y         |
|-------------|-------|-------|-----------|-----------|
| Bigloo      | 7     | x     | 7         | 7         |
| Biwa        | 7     | 7     | 7         | 7         |
| Chez        | error | error | 7         | 7         |
| Chibi       | error | error | 7         | 7         |
| Chicken     | 7     | 7     | 7         | 7         |
| Cyclone     | 7     | error | 7         | error     |
| Gambit      | error | error | error     | error     |
| Gauche      | 7     | 7     | 7         | 7         |
| Guile       | 7     | error | 7         | error     |
| Kawa        | 7     | error | 7         | 7         |
| LIPS        | 7     | error | error (*) | error (*) |
| Loko        | error | error | error     | error     |
| MIT         | error | error | error     | error     |
| Racket      | 7     | error | 7         | error     |
| Sagittarius | 7     | 7     | 7         | 7         |
| Scheme48    | error | error | 7         | 7         |
| Scheme 9    | error | error | 7         | 7         |
| SCM         | 7     | 7     | 7         | 7         |
| STklos      | 7     | 7     | 7         | 7         |
| Tinyscheme  | 7     | 7     | 7         | 7         |

* LIPS does not recognise the `else` clause when it's the only 
expression in `cond`.

J.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.