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


From: Linus Björnstam
Subject: Re: [Patch] definitions in when, unless, do as well as in cond- and case-clauses
Date: Thu, 17 Jun 2021 14:57:58 +0200
User-agent: Cyrus-JMAP/3.5.0-alpha0-526-gf020ecf851-fm-20210616.001-gf020ecf8

Guile already does definitions in expression context in the bodies of lambda 
and let-variants. I think this is not a big problem since any valid r6rs code 
is still valid guile.

The discussion is in my opinion whether guile's r6rs modules should enforce 
this behaviour. That might be a good thing, even though we will provide 2 cons 
and case forms to do that.

-- 
  Linus Björnstam

On Thu, 17 Jun 2021, at 11:06, Maxime Devos wrote:
> Linus Björnstam schreef op wo 16-06-2021 om 21:11 [+0200]:
> > 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"))  [...]
> 
> This seems a useful change to me. However, this is not valid R6RS.
> From <http://www.r6rs.org/final/r6rs.pdf>:
> 
> (cond hcond clause1i hcond clause2i . . . ) syntax
> => auxiliary syntax
> else auxiliary syntax
> Syntax: Each hcond clausei must be of the form
> (htesti hexpression1i . . . )
> where htesti is an expression. Alternatively, a
> hcond clausei may be of the form
> (htesti => hexpressioni)
> 
> This seems a compatibility pitfall, so maybe note
> in the documentation that using definitions in the clauses
> is a Guile and Racket extension and not standard R6RS?
> 
> (I try to write Scheme code as R6RS / R7RS library & define-library
> forms, importing mostly R6RS / R7RS & SRFI libraries, though I occasionally
> use a Guile extension.)
> 
> Greetings,
> Maxime
> 
> Attachments:
> * signature.asc



reply via email to

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