Re: define use in expression context

Maxime Devos <[email protected]> Sun, 13 Jul 2025 14:24:14 +0200
Newsgroups gmane.lisp.guile.user
Message-ID <[email protected]>
On 12/07/2025 11:12, 胡峻豪 wrote:
> (do ((i 0 (+ i 1)))
>
>      ((= i 2))
>
>      (begin
>
>          (define x 2)
>
>          (display x)
>
>      )
>
> )

Can be done by redefining 'do'

Basically, let '(new-do x y body ...)' be '(do x y (let () body ...))' 
and redefine 'do' by 'new-do' in some way (it is convenient to import 
the old 'do' under a different name). Or take the old definition of 
'do', copy it, and insert a surrounding 'let' in the right lace.

Same applies to many other situations.

(Also, that 'begin' serves no purpose there.)

Best regards,
Maxime Devos