unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Taylan Kammer <taylan.kammer@gmail.com>
To: Damien Mattei <damien.mattei@gmail.com>,
	guile-user <guile-user@gnu.org>,
	 guile-devel <guile-devel@gnu.org>
Subject: Re: case source code
Date: Mon, 12 Sep 2022 10:47:37 +0200	[thread overview]
Message-ID: <603460d9-e0a3-b5d5-e38a-977dfbc20285@gmail.com> (raw)
In-Reply-To: <CADEOadfEieDGTg3xG23y+rvEQ15Qeby_osE2u-=DA_v+WR8zKw@mail.gmail.com>

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




  parent reply	other threads:[~2022-09-12  8:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12  7:42 case source code Damien Mattei
2022-09-12  7:46 ` Zelphir Kaltstahl
2022-09-12  8:27   ` Damien Mattei
2022-09-12  8:30     ` Damien Mattei
2022-09-12  8:47 ` Taylan Kammer [this message]
2022-09-13  9:18   ` Damien Mattei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=603460d9-e0a3-b5d5-e38a-977dfbc20285@gmail.com \
    --to=taylan.kammer@gmail.com \
    --cc=damien.mattei@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).