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: [Patch] definitions in when, unless, do as well as in cond- and case-clauses
Date: Fri, 4 Feb 2022 21:11:52 +0100	[thread overview]
Message-ID: <CAGua6m2ZwojoYzaC3eLXoR+GcEn0Ra1=tTdBHva4J=VMYU0eDA@mail.gmail.com> (raw)
In-Reply-To: <CAGua6m1Cqe=aLOD7-jfzoqxP1aOxvWn3=UgcKyk+Dx7_51Bq3w@mail.gmail.com>

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

---------- Forwarded message ---------
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
Date: Thu, Feb 3, 2022 at 5:41 PM
Subject: Re: [Patch] definitions in when, unless, do as well as in cond-
and case-clauses
To: Linus Björnstam <linus.bjornstam@veryfast.biz>


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.

(if 1 (define a 1) (define a 2)) will not work at the top level because of
an implicit let. If you need implicit defines a simple macro for those are
easy and if we need to state a syntax in stone for those, we should name
them differently like when-let  unless-let if-let cond-let case-let.

On Thu, Feb 3, 2022 at 11:55 AM Linus Björnstam <
linus.bjornstam@veryfast.biz> wrote:

> Hi guys,
>
> It looks like a 3.0.8 might be happening. I am curious to know whether
> this (perhaps minus the do form) is considered something that the
> maintainers of guile could find interesting.
>
> If subset compatibility of r6|7rs is desired, I could provide a patch for
> those files as well so that they enforce the distinction between definition
> and expression context.
>
> I myself find this a worthwhile patch since it has no drawbacks. a (let ()
> ...) without definitions does not start a new lexical context and runs as
> fast as a begin, so there should be no performance regressions.
>
> It also removes the last bodies in guile forms that have a definition
> context, which may be confusing for beginners.
>
> I would say that the compatibility question with the enforcing cond of
> rnrs is the only thing that needs proper addressing.
>
> Best
>   Linus Björnstam
>
> On Wed, 16 Jun 2021, at 21:11, Linus Björnstam wrote:
> > Hi there!
> >
> > This patch updates some derived conditional forms (and do and and-let*)
> > to support definitions in expression context. Meaning it makes this
> > valid code:
> >
> > (cond
> >   ((pred? arg)
> >     (define a (something arg))
> >     (when (error-case a)
> >       (error "a is broken"))
> >     (define b (something2 a))
> >     (when  (= 3 *log-level*)
> >       (display "logging something1 and 2 as successful"))
> >     (define c (something3 b a))
> >     (when (odd? c)
> >        (error "something went wrong in something3"))
> >     c)
> >   (else
> >     ;;chosen by fair dice roll. Guaranteed to be random
> >     4)))
> >
> > While awful, is sometimes what the world makes us do.
> >
> > The change means cond, case, when and unless behaves like it does in
> > racket. Do was below case, so I changed that as well, and will actually
> > become yet another way guile is superior to racket.
> >
> > I did also change the documentation, but I learned english by watching
> > Beverly Hills cop, so that might need some fine touches by a capable
> > english speaker.
> >
> >
> > Best regards
> >   Linus Björnstam
> > Attachments:
> > * 0001-Allow-definitions-in-derived-conditional-forms.patch
>
>

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

  parent reply	other threads:[~2022-02-04 20:11 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     ` Stefan Israelsson Tampe [this message]
2022-02-04 20:58       ` Fwd: " Maxime Devos
     [not found]         ` <CAGua6m11r27x=rq4S4fF09vHY+S-Az7GOZfmoT41hEBDSkLJQg@mail.gmail.com>
2022-02-04 21:40           ` Fwd: " Stefan Israelsson Tampe
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='CAGua6m2ZwojoYzaC3eLXoR+GcEn0Ra1=tTdBHva4J=VMYU0eDA@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).