[gambit-list] Transparently handling of source object?

Meng Zhang wsxiaoys.lh at gmail.com
Sat Feb 9 04:49:06 EST 2013

Hi everyone,

In gambit, when dealing with macros, it became hard to debug because the
source information got lost
in expander so we couldn't generate good debug information.

For gambit's internal macros, it mostly use the ##define-syntax
to acquire source-object instead of
stripped s-expression.

It's doable with lisp style macros, (though it need more work to
reimplement your original macros.)
But things became hard to deal with if taking hygienic macros into
consideration, as syntax-rules expander
will apply pattern match to the s-expression.

I was wondering if there's any possibilities that make source objects
completely transparently to the macro
expander, for example:


(define-syntax test ;; x passed in as a source object
  (syntax-rules ()
    ((_ x) (pp (syntax-location x)))))

(test 3)

  File: test.scm, Line: ...

I've thought following solutions:
1. Make custom exception handlers for type-exception, and recall the
procedure if we found the callee args
is an source-object. primitives like car, cdr will work directly
pros: No need to do internal changes.
cons: type-exception will not be raised by functions take general
parameters, like pp, pair?, list?

2. Adding a new subtype, and let every primitives call it as-is.
pros: The whole system worked as is,  there's a similar solution for
promise auto-force in gambit so we can
refer from.
cons: This will added possible load to runtime system.(every primitives
have to check this type and unbox it).

As I'm not an expert to gambit's internal implementation, I would like to
ask if there's other possible solution to
this problem?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20130209/9cf57f1c/attachment.htm>

More information about the Gambit-list mailing list