* syntax-source
@ 2011-04-16 20:12 Stefan Israelsson Tampe
2011-04-17 2:21 ` syntax-source Mark H Weaver
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Israelsson Tampe @ 2011-04-16 20:12 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 742 bytes --]
Hi,
I want to get source location of a macro form and played a little with
syntax-source.
This should then print out something.
(define-syntax <+>
(lambda (x)
(syntax-case x ()
((o a b)
(pk (syntax-source x))
#'(+ a b)))))
(<+> 1 2)
In trying to use the location of x resulted in the toplevel form location
and not the <+> form in a more complex example.
and using #'o or #'a or #'b in stead of x on syntax-source form will lead
to pk prints out #f.
So the question is if it is possible to get a more exact location
information of the (<+> 1 2)
and in that case how?
Anyway a brief discussion how source and meta information is transported in
the guile macro framework would be
interesting.
Regards
Stefan
[-- Attachment #2: Type: text/html, Size: 869 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: syntax-source
2011-04-16 20:12 syntax-source Stefan Israelsson Tampe
@ 2011-04-17 2:21 ` Mark H Weaver
0 siblings, 0 replies; 2+ messages in thread
From: Mark H Weaver @ 2011-04-17 2:21 UTC (permalink / raw)
To: Stefan Israelsson Tampe; +Cc: guile-devel
Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:
> I want to get source location of a macro form and played a little with
> syntax-source. This should then print out something.
>
> (define-syntax <+>
> (lambda (x)
> (syntax-case x ()
> ((o a b)
> (pk (syntax-source x))
> #'(+ a b)))))
>
> (<+> 1 2)
>
> In trying to use the location of x resulted in the toplevel form
> location and not the <+> form in a more complex example. and using
> #'o or #'a or #'b in stead of x on syntax-source form will lead to pk
> prints out #f.
Source properties are associated with source forms using an eq? hash
table, and thus work only for parenthesized expressions, not for atoms.
See section 6.52.2 of the manual for more on this.
Best,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-17 2:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-16 20:12 syntax-source Stefan Israelsson Tampe
2011-04-17 2:21 ` syntax-source Mark H Weaver
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).