Re: cond clause does not allow definitions

2024-05-24 Thread Linus Björnstam
I submitted a patch that expanded definition context to more places (cond, case, when, unless etc). I dont know what happened to that. I submitted it while moving and promptly forgot about it after some discussion. -- Linus Björnstam On Wed, 22 May 2024, at 21:26, Damien Mattei wrote: > scheme@

Re: cond clause does not allow definitions

2024-05-23 Thread Pierpaolo Bernardi
On Thu, May 23, 2024 at 4:25 PM Damien Mattei wrote: > On Thu, May 23, 2024 at 12:37 AM Jeronimo Pellegrini wrote: >> 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. > yes i spent m

Re: cond clause does not allow definitions

2024-05-23 Thread Damien Mattei
On Thu, May 23, 2024 at 12:37 AM Jeronimo Pellegrini wrote: > 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. yes ,unless they wanted Chez scheme to behave as Python :-) : if True: x

Re: cond clause does not allow definitions

2024-05-22 Thread Jeronimo Pellegrini
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

Re: cond clause does not allow definitions

2024-05-22 Thread Damien Mattei
hello Maxime, On Thu, May 23, 2024 at 12:12 AM Maxime Devos wrote: > >but it is allowed in else clause: > > >scheme@(guile-user)> (cond (else (define x 7) x)) > > >$4 = 7 > > > > > >not really logic > > > > Probably in the implementation of ‘cond’, (cond (else X)) reduces to ‘X’. > > > > It’s tr

RE: cond clause does not allow definitions

2024-05-22 Thread Maxime Devos
>but it is allowed in else clause: >scheme@(guile-user)> (cond (else (define x 7) x)) >$4 = 7 > >not really logic Probably in the implementation of ‘cond’, (cond (else X)) reduces to ‘X’. It’s tricky to ensure the same behaviour here as is the case when there is more than only the ‘else’ clause

Re: cond clause does not allow definitions

2024-05-22 Thread Damien Mattei
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 soft

Re: cond clause does not allow definitions

2024-05-22 Thread Pierpaolo Bernardi
On Wed, May 22, 2024 at 10:08 PM Jeronimo Pellegrini 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 |

Re: cond clause does not allow definitions

2024-05-22 Thread lloda
Fwiw Guile isn't 100% consistent about this, for example match forms don't allow definitions and maybe some other form that I don't recall atm. > On 22 May 2024, at 22:37, lloda wrote: > > > This is probably > http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commitdiff;h=764e3614b8c13de604

Re: cond clause does not allow definitions

2024-05-22 Thread lloda
This is probably http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commitdiff;h=764e3614b8c13de604399572a67d071621e9ca21 and the next commit that documents the change. It was after 3.0.9.

Re: cond clause does not allow definitions

2024-05-22 Thread Damien Mattei
i wanted to write 'than your' not 'than you' :-/ On Wed, May 22, 2024 at 10:33 PM Damien Mattei wrote: > Bonjour, > > so it is with the version i currently use which is older than you: > (base) mattei@mbp-touch-bar library-FunctProg % guile > GNU Guile 3.0.8.99-f3ea8 > Copyright (C) 1995-2022 F

Re: cond clause does not allow definitions

2024-05-22 Thread Damien Mattei
Bonjour, so it is with the version i currently use which is older than you: (base) mattei@mbp-touch-bar library-FunctProg % guile 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 fr

Re: cond clause does not allow definitions

2024-05-22 Thread Jeronimo Pellegrini
Hello! On 2024-05-22 16:26, Damien Mattei wrote: scheme@(guile-user)> (cond (#t (define x 7) x)) While compiling expression: Syntax error: unknown file:7:10: definition in expression context, where definitions are not allowed, in form (define x 7) I get no error here (Guile 3.0.9.164-e1690,