[racket] Metaprogramming with scheme

From: Noel Welsh (noelwelsh at gmail.com)
Date: Mon Jun 21 07:55:46 EDT 2010

Please reply to the list; you'll get more help that way. (Also, I'll
ignore your emails if you don't.)

On Mon, Jun 21, 2010 at 12:29 PM, Valeriya Pudova
<valery at digitalchile.net> wrote:
> The question is: when in the eval-synax process there will be called some
> function how that function can to reffer to the current syntax-object?

foo.ss:

(foo 1 2)

Code:

(with-input-from-file "foo.ss"
  (lambda ()
    (parameterize ([error-display-handler (lambda (name . stuff)
(printf "Got ~a ~a\n" name stuff))])
      (eval-syntax (read-syntax 'foo.ss)))))

Output:

Got foo.ss::0: compile: unbound identifier (and no #%app syntax
transformer is bound) at: foo in: (foo 1 2) (#(struct:exn:fail:syntax
foo.ss::0: compile: unbound identifier (and no #%app syntax
transformer is bound) at: foo in: (foo 1 2) #<continuation-mark-set>
(#<syntax::2 foo>)))

So the exception structure has the syntax object you want.

N.


Posted on the users mailing list.