> On Apr 6, 2016, at 8:29 PM, Matthew Butterick wrote:
> So you can repair your macro by matching to `y-coord` as a pattern:
>
> ;;;
>
> #lang racket
> (require rackunit)
>
> (define-syntax y-coord
> (syntax-id-rules ()
> [y-coord point-y]))
>
> (struct point (x y))
> (defi
> Expanding `y-coord` by itself leads to the error.
I've tripped over this, so just to elaborate slightly.
`syntax-id-rules` will work, but your current macro:
;;;
(define-syntax y-coord
(syntax-id-rules (map)
[(map y-coord lst) (map (lambda (p)
(
Adding `(define y-coord points-y)` should make the original example work
as-is.
Vincent
On Wed, 06 Apr 2016 15:45:56 -0500,
Daniel Prager wrote:
>
> (map point-y points) gives the expected result without recourse to a
> macro.
>
> Or is y-coord intended as a simplified example of something els
This is "bad syntax" for the same reason that `(map or '())` is "bad
syntax".
When the macro expander sees `(map y-coord points)`, it recognizes `map` as
a variable binding and then tries expanding each argument to `map`.
Expanding `y-coord` by itself leads to the error.
You could instead define `
Oops, forgot to include the users list.
_
From: Jos Koot [mailto:jos.k...@gmail.com]
Sent: miƩrcoles, 06 de abril de 2016 23:03
To: 'Richard Adler'
Subject: RE: [racket-users] macros within expressions.
You don't need a macro here. Why not simply:
(map point-y point
(map point-y points) gives the expected result without recourse to a macro.
Or is y-coord intended as a simplified example of something else?
Dan
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving
I am trying to use a macro, y-coord, in the following way:
(struct point (x y))
(define points (list (point 25 25) (point 33 54) (point 10 120))
(map y-coord points)
I am expecting the result:
'(25 54 120)
and the error is "y-coord: bad syntax in: y-coord
Here is the macro:
(define-syntax y-c
7 matches
Mail list logo