[racket] filtering syntax

From: Veer Singh (veer.chah at gmail.com)
Date: Wed Jan 18 07:05:22 EST 2012

Add

(require (for-syntax syntax/parse))

or

use syntax-case and wrap it in begin i.e (begin define id-lst .....)




On Wed, Jan 18, 2012 at 5:36 PM, Marijn <hkBst at gentoo.org> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 18-01-12 11:36, Veer Singh wrote:
> > This seems to work (blind hack),
>
> Unfortunately it doesn't work:
> _: wildcard not allowed as an expression in: (_ ((id:id expr:expr ...)
> ...))
>
> in line 3 of the following:
>
> > (define-syntax (depgraph stx) (syntax-parse stx [(_ ((id:id
> > expr:expr ...) ...))
> >
> > (define id-lst (syntax->list #'(id ...))) (define ctx
> > (syntax-local-make-definition-context)) (syntax-local-bind-syntaxes
> > id-lst #f ctx) (with-syntax ([p #'((lambda () expr ...) ...)])
> > (define p-lst (syntax->list #'p)) (define vars (map (lambda (e)
> > (free-vars (local-expand e 'expression '() ctx))) p-lst))
> > (with-syntax ([((f ...) ...) vars]) #''((id (f ...)) ...)))]))
> >
> >
> > (define simple-arith (depgraph ((a #f) (b (* 3 a)) (c (+ 5 a b)) (d
> > (let ((a 9)) (- c a))) )))
> >
> > simple-arith ;((a ()) (b (a)) (c (b a)) (d (c)))
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.18 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk8WtcAACgkQp/VmCx0OL2xvBQCgxxM7UrjQqXhK/djusC9apPey
> CrYAn19TFKmxRsTOnzVZoknhdrY3BuJC
> =6bty
> -----END PGP SIGNATURE-----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120118/e5858c96/attachment.html>

Posted on the users mailing list.