On Tue, Feb 7, 2012 at 10:37 PM, Andy Wingo <wingo@pobox.com> wrote:
On Sat 04 Feb 2012 21:31, Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:

> #'(begin
>      (define f fkn-definition)
>      (define-syntax name
>          (make-syntax-case-transformer
>                (make-stxclass
>                      ...
>                      (datum->syntax #'name 'f)
>                      ...))))
>
> This code expans ok in the toplevel. But if expanded elsewhere in definition
> context f is not reached from the data associated with the macro.

So, a few things.

One is that if #'name came from the macro invocation but f did not, then
indeed f is not visible from #'name.

That this works at the top level is a byproduct of a bug in stable-2.0
that is "fixed" in master.  (There are two bugs: one about module
scoping of introduced toplevel identifiers, and another about the
symbolic names of introduced toplevel identifiers.  See
https://savannah.gnu.org/bugs/?31472.)

> So how can I make this to work in both contexts?

Just use #'f instead of (datum->syntax #'name 'f).

I would love to use this, but when I tried that, the code failed in some cases, maybe because of the bugs you mensioned? I will probable fix this when you merge the fix mensioned above into stable
meanwhile one can use with-syntax-class etc like constructs if in local scope.
/Stefan