guile-user
[Top][All Lists]
Advanced

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

Re: case source code


From: Damien Mattei
Subject: Re: case source code
Date: Mon, 12 Sep 2022 10:27:23 +0200

sorry if my question was unclear , i search the source code if it exist in
scheme with macro (or not) but not in C for the 'case function (procedure
or macro) , i want to modify the code to allow inner definitions the way i
do it for example with 'do:

;; with a definition inside only the new version works:
;; (do ((i 1 (1+ i))
;;      (p 3 (* 3 p)))
;;     ((> i 4)
;;      p)
;;   (define x 7)
;;   (set! p (+ p i x)))
;; $3 = 1257

(define-syntax do

  (syntax-rules ()

    ((do ((var init step ...) ...)

         (test expr ...)

         command ...)

     (letrec

       ((loop

         (lambda (var ...)

           (if test

               ;;(begin
      (let ()

                 #f ; avoid empty begin

                 expr ...)

               ;;(begin
      (let ()

                 command

                 ...

                 (loop (do "step" var step ...)

                       ...))))))

       (loop init ...)))

    ((do "step" x)

     x)

    ((do "step" x y)

     y)))

regards,
Damien

On Mon, Sep 12, 2022 at 9:46 AM Zelphir Kaltstahl <
zelphirkaltstahl@posteo.de> wrote:

> Hello Damien,
>
> On 9/12/22 09:42, Damien Mattei wrote:
> > Hello,
> > i can not find in the scheme community a definition of 'case in term of
> > macro as for when, unless,while,do... does anyone have it?
> > thanks,
> > Damien
>
> Can you give an example of what form you mean?
>
> Regards,
> Zelphir
>
> --
> repositories: https://notabug.org/ZelphirKaltstahl
>
>


reply via email to

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