[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:30:40 +0200 |
just forget to add , if it is unclear it is 'case of scheme:
https://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/if-cond-case.html#if-cond-case
On Mon, Sep 12, 2022 at 10:27 AM Damien Mattei <damien.mattei@gmail.com>
wrote:
> 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
>>
>>