[gambit-list] macros, exceptions, line numbers

lowly coder lowlycoder at huoyanjinjing.com
Thu Oct 15 21:42:24 EDT 2009


take a look at:

cat test.scm; gsi test.scm
(define-macro (for var start end . body)
  `(do ((,var ,start (+ ,var 1)))
      ((= ,var ,end))
      , at body))


(for i 0 2
     (display i)
     (newline))


(for i 0 2
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     (/ i a)
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     'this-line-does-nothing
     )


0
1
*** ERROR IN #<procedure #2>, "test.scm"@12.1 -- Unbound variable: a



ignore the fact taht ,end is evaluated twice:

note that the error is on line "12", which is the (for i 0 2 line ...
not the (/ i a) line; i can understand that since the macro expansion
happens before the code is run, the entire 'chunk' gets grouped to the
line where the macro is expanded at

however, is there anyway I can have the "LINE_NUMBER" information
passed along with define-macro?

thanks!



More information about the Gambit-list mailing list