[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
quoted data in macro expansion
Am I correct in understanding that any quoted S-expressions, in either a
macro "parameter" or in a template, is copied? This is of course needed
for any quote expression in the template if it spliced in. However, in
many (most? all?) existing syntax-case and syntax-rules implementations
a quoted form in macro parameter that is not "destructured" is used
verbatim, and likewise for a quoted form in a template if it contains no
I don't know if this is a big deal, but it breaks pair identity in cases
where it is preserved in existing implementations. This seems to make
SRFI-72 essentially incompatible with SRFI-38, in the sense that you
can't use of SRFI-38 shared structure in programs (though it is still
available for external data). And of course cycles are prohibited.
A solution might be something like the following: when creating a syntax
object from a pair or vector, enter both the original pair/vector and
the corresponding syntax pair/vector in a table. (If the original
pair/vector exists in the table, re-use the syntax pair/vector.) Then
quote and related forms (e.g. syntax->datum) does the inverse mapping.
Of course for this to be efficient, you probably need a (non-portable)
object hash table, though various tricks are possible.