---------- Forwarded message --------- From: Stefan Israelsson Tampe Date: Fri, Feb 4, 2022 at 10:40 PM Subject: Re: Fwd: [Patch] definitions in when, unless, do as well as in cond- and case-clauses To: Maxime Devos I tested and yes you are right, in guile conditionals do not have this property and similarly, all other directives I could find does not work, but because scheme has macros this is not super important. So then we should fix this to replace the definition from, (if p x y) to (if p (let () x) (let () y)) And then all other conditional, that is expressed as macros from if have the correct a let binding if we want this. This change will make new code non compilable by old guile's but that is not a huge issue, just make a macro package that you introduce conditionally to your project and recompile. The good thing is namely that issues will brake at compile time and not through some mysterious run time bug. Anyhow conditional defining vars is a common theme in other languages so I think it was kind of natural to implement if as it was done. Regards Stefan On Fri, Feb 4, 2022 at 9:58 PM Maxime Devos wrote: > Stefan Israelsson Tampe schreef op vr 04-02-2022 om 21:11 [+0100]: > > using an implicit let in conditionals are bad in that you cannot > > escape from the let form which means that you loos > > conditional defines for example in the toplevel. e.g. [...] > > While old versions of Guile (Guile 1.8?) did support conditional > defines on the top-level, new versions of Guile (Guile 2.0 and later) > don't: > > (if #true > (define x 'foo) > (define x 'bar)) > > While compiling expression: > Syntax error: > unknown file:2:4: definition in expression context, where definitions > are not allowed, in form (define x (quote foo)) > > The following still works though of course: > > (define x (if #true 'foo 'bar)) > > So for the current version of Guile (3.0.X), there don't appear to be > backwards-compatibility problems in this area. > > Greetings, > Maxime. >