[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: syntax-case guards
From: |
Ian Price |
Subject: |
Re: syntax-case guards |
Date: |
Mon, 04 Feb 2013 01:14:57 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
Aleix Conchillo Flaqué <address@hidden> writes:
> Hi,
>
> I'm trying to use a syntax-case guard when the pattern has ellipsis.
> So I have something like,
>
> ((_ (struct (k v) ...))
> (string? (syntax->datum #'k))
> exp)
You were probably wanting this to apply to each and every k
individually? syntax-case does not work this way. Patterns with ellipsis
are expected to be matched with templates with ellipsis. Sorry.
> So, how do I make the guard when I have a pattern with ellipsis?
using every from (srfi srfi-1) or for-all from (rnrs lists) [same
procedure different name] you get
(every (compose string? syntax->datum) #'(k ...))
As an aside, this won't work in Racket, since they also make lists into
syntax objects, unlike psyntax or the r6rs.
--
Ian Price -- shift-reset.com
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"