guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Patch] definitions in when, unless, do as well as in cond- and case


From: Linus Björnstam
Subject: Re: [Patch] definitions in when, unless, do as well as in cond- and case-clauses
Date: Thu, 03 Feb 2022 11:48:22 +0100
User-agent: Cyrus-JMAP/3.5.0-alpha0-4585-ga9d9773056-fm-20220113.001-ga9d97730

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]