From: Damien Mattei <damien.mattei@gmail.com>
To: Pierpaolo Bernardi <olopierpa@gmail.com>
Cc: Jeronimo Pellegrini <j_p@aleph0.info>, guile-user <guile-user@gnu.org>
Subject: Re: cond clause does not allow definitions
Date: Thu, 23 May 2024 00:09:53 +0200 [thread overview]
Message-ID: <CADEOaddLEbptwTcFsQQ3Q-3osNw1nyDBD4GW3+Sc-++9i13-+g@mail.gmail.com> (raw)
In-Reply-To: <CANY8u7E3gTQpdwBh-XZq9YUQMg5aufNr1XxZPrE8Abz0VbNRWg@mail.gmail.com>
in the version below it seems that else in cond with definition works alone
but not when there is other conditions before:
GNU Guile 3.0.8.99-f3ea8
Copyright (C) 1995-2022 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> (cond (else (define x 7) x))
$1 = 7
scheme@(guile-user)> (cond (#f 'never) (else (define x 7) x))
While compiling expression:
Syntax error:
unknown file:2:24: definition in expression context, where definitions are
not allowed, in form (define x 7)
i understand that because in my code, that i can not write all here, i
had to change:
#`(cond (#,test (let ()
#,@L-then))
(else
#,@L-else)))
#`(cond (#,test (let ()
#,@L-then))
(else
(let ()
#,@L-else))))
add a (let () in the else of cond too to encapsulate the possible
definitions in #,@L-else
now i understand that and it is late here...
good night
On Wed, May 22, 2024 at 11:08 PM Pierpaolo Bernardi <olopierpa@gmail.com>
wrote:
> On Wed, May 22, 2024 at 10:08 PM Jeronimo Pellegrini <j_p@aleph0.info>
> wrote:
>
> > A: (cond (#t (define x 7) x))
> > B: (cond (else (define x 7) x))
> >
> > | system | A | B |
> > |-------------|-------|-------|
> > | Bigloo | 7 | 7 |
> > | Biwa | 7 | 7 |
> > | Chez | error | 7 |
> > | Chibi | error | 7 |
>
> 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?
>
next prev parent reply other threads:[~2024-05-22 22:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 19:26 cond clause does not allow definitions Damien Mattei
2024-05-22 20:07 ` Jeronimo Pellegrini
2024-05-22 20:33 ` Damien Mattei
2024-05-22 20:34 ` Damien Mattei
2024-05-22 20:37 ` lloda
2024-05-22 20:40 ` lloda
2024-05-22 21:07 ` Pierpaolo Bernardi
2024-05-22 22:09 ` Damien Mattei [this message]
2024-05-22 22:37 ` Jeronimo Pellegrini
2024-05-23 14:25 ` Damien Mattei
2024-05-23 14:59 ` Pierpaolo Bernardi
2024-05-22 22:12 ` Maxime Devos
2024-05-22 22:34 ` Damien Mattei
2024-05-24 14:27 ` Linus Björnstam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADEOaddLEbptwTcFsQQ3Q-3osNw1nyDBD4GW3+Sc-++9i13-+g@mail.gmail.com \
--to=damien.mattei@gmail.com \
--cc=guile-user@gnu.org \
--cc=j_p@aleph0.info \
--cc=olopierpa@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).