unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: Fwd: Fwd: [Patch] definitions in when, unless, do as well as in cond- and case-clauses
Date: Fri, 4 Feb 2022 22:40:38 +0100	[thread overview]
Message-ID: <CAGua6m35kHv9NzrAkX7hbDHBZ-wC_Fq99UzvJWCnuf2VqC90kA@mail.gmail.com> (raw)
In-Reply-To: <CAGua6m11r27x=rq4S4fF09vHY+S-Az7GOZfmoT41hEBDSkLJQg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2088 bytes --]

---------- Forwarded message ---------
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
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 <maximedevos@telenet.be>


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 <maximedevos@telenet.be> 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.
>

[-- Attachment #2: Type: text/html, Size: 3062 bytes --]

  parent reply	other threads:[~2022-02-04 21:40 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 19:11 [Patch] definitions in when, unless, do as well as in cond- and case-clauses Linus Björnstam
2021-06-17  9:06 ` Maxime Devos
2021-06-17 12:57   ` Linus Björnstam
2021-06-17 13:54     ` Maxime Devos
2022-02-03 10:48 ` Linus Björnstam
     [not found]   ` <CAGua6m1Cqe=aLOD7-jfzoqxP1aOxvWn3=UgcKyk+Dx7_51Bq3w@mail.gmail.com>
2022-02-04 20:11     ` Fwd: " Stefan Israelsson Tampe
2022-02-04 20:58       ` Maxime Devos
     [not found]         ` <CAGua6m11r27x=rq4S4fF09vHY+S-Az7GOZfmoT41hEBDSkLJQg@mail.gmail.com>
2022-02-04 21:40           ` Stefan Israelsson Tampe [this message]
2022-02-04 23:39           ` Maxime Devos
2022-02-05  1:14             ` Stefan Israelsson Tampe
2022-02-05 10:55               ` Maxime Devos
2022-02-05 17:31                 ` Stefan Israelsson Tampe
2022-02-05 17:36                   ` Maxime Devos
2022-02-06  6:44                   ` Linus Björnstam
2022-02-06  9:27                     ` tomas
2022-02-06  9:40                       ` Maxime Devos
2022-02-06  9:45                       ` Linus Björnstam
2022-02-06 10:48                         ` tomas
2022-02-06 20:13                           ` Stefan Israelsson Tampe
2022-02-06 20:28                             ` Maxime Devos
2022-02-06 20:31                               ` tomas
     [not found]                               ` <CAGua6m3BHMXOhT3PHZcxdqHqHomTFESO31j5CcSNK3pbA7K-Kg@mail.gmail.com>
2022-02-06 21:26                                 ` Maxime Devos
2022-02-06 21:27                                   ` Maxime Devos
2022-02-07  5:56                             ` 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=CAGua6m35kHv9NzrAkX7hbDHBZ-wC_Fq99UzvJWCnuf2VqC90kA@mail.gmail.com \
    --to=stefan.itampe@gmail.com \
    --cc=guile-devel@gnu.org \
    /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).