[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: |
Tue, 13 Sep 2022 11:18:57 +0200 |
thanks, if just replaced the 'begin by 'let () to allow internal
definitions but i haven't test it yet (finally no need in my code of define
internal at this point)
regards,
Damien
On Mon, Sep 12, 2022 at 10:47 AM Taylan Kammer <taylan.kammer@gmail.com>
wrote:
> On 12.09.2022 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
>
> The RnRS often contain such definitions. The following is taken from
> R7RS-small:
>
> (define-syntax case
> (syntax-rules (else =>)
> ((case (key ...) clauses ...)
> (let ((atom-key (key ...)))
> (case atom-key clauses ...)))
> ((case key (else => result))
> (result key))
> ((case key
> (else result1 result2 ...))
> (begin result1 result2 ...))
> ((case key
> ((atoms ...) result1 result2 ...))
> (if (memv key ’(atoms ...))
> (begin result1 result2 ...)))
> ((case key
> ((atoms ...) => result))
> (if (memv key ’(atoms ...))
> (result key)))
> ((case key
> ((atoms ...) => result)
> clause clauses ...)
> (if (memv key ’(atoms ...))
> (result key)
> (case key clause clauses ...)))
> ((case key
> ((atoms ...) result1 result2 ...)
> clause clauses ...)
> (if (memv key ’(atoms ...))
> (begin result1 result2 ...)
> (case key clause clauses ...))))
>
> --
> Taylan
>
>