Arc Forumnew | comments | leaders | submitlogin
2 points by almkglor 5928 days ago | link | parent

Why not just mod 'mac to something like (docstring extraction and name redefinition elided):

  (mac mac (name args . body)
    `(set ,name
       (annotate 'mac
         (fn ,(cons 'expansion-context args)
           ,@body))))
Then insert stuff in Scheme-side 'ac to use (apply macro the-free-list-or-whatever (cdr ex)) instead of (apply macro (cdr ex))

That way macros that need it can get it, while macros which don't need it can ignore it.

We can potentially define 'expansion-context as a table or function, and potentially we could allow an implementation to have expansion-context!line, say provide line number etc. information so that the macro can give decent error messages. Of course if we have a dorky backend (like mzscheme) then we can just have it return expansion-context!line as nil, because it can't somehow extract line numbers, but for implementations that can, then good.

edit: Oh and ye: the 'ac compiler on scheme-side really does keep a list of bound variables ^^