Am Fr., 28. Aug. 2020 um 16:24 Uhr schrieb Alex Shinn <xxxxxx@gmail.com>:However, your interpretation that cyclic literals are therefore allowed in any macro that eventually quotes the cycle makes less sense.To suggest that:'#=0(1 . #0#) ; legal in R7RSNot suggesting; this is explicitly stated as legal in R7RS.`#=0(1 . #0#) ; illegal in R7RSLikewise, this is explicitly stated as illegal in R7RS. And it does make sense because when quasiquote is implemented as a (syntax-rules) macro, it has to scan its template, for which it *must* be illegal for the template to contain any cyclic datums.(let-syntax ((q (syntax-rules () ((_ x) 'x))))(q #=0(1 . #0#))) ; legal?is absurd.Quite the opposite; I would call it absurd if the legalness of that code would be absurd (under the premise that quoted cyclic datums are allowed as in R7RS). Try to formalize the restriction you have in mind and you'll see that it doesn't play well with the rest of the language.And again, it has nothing to do with quasiquote.(NB In non-R7RS implementations that allow cyclic literals like Chez, this code is likewise valid. Even formalizing the restriction you have in mind )Moreover beyond these simple cases there is the general problem of extending the syntax-rules pattern matching and template substitution to handle cycles in the general case, which is implied by allowing indirect quoting.I think no one proposed to extend the syntax-rules pattern matching to be able to detect cycles. (And that's, as I wrote above, one reason why cyclic literals have to be invalid inside quasiquote.) The quote form, however, is no macro that inspects its sole argument as a syntax-rules macro. Nor does the `q` macro from above inspects its argument.There is no mention of any of this in the spec.And there doesn't have to be.The only reasonable assumption is that it means exactly what it says - the cyclic literal should be quoted.This is actually not what the spec says (fortunately!). It says: "It is an error for a program or library to include circular
references except in literals." Now, literals are a particular expression form, but not every literal appears in quoted form.Even more can be inferred: Literals are an expression type like variable references or procedure calls. But whether a particular piece of code is a variable reference or procedure call depends on its lexical context and how it is expanded during macro expansion. The same goes for literals (as for every other expression type). So any restriction (applying to literals) can only apply to the result of the expansion.Just for the record, here is another reason why simply skipping quoted literals by any Petrofsky-like cannot work (even if assume that all problematic literals appear in explicit quotes):(foo (quote <datum>))I don't know why you keep beating this dead horse. I've already acknowledged the bug.I didn't want to offend you; if I did so, please accept my apology (and I didn't mean you to reacknowledge whatever bug).The misunderstanding is probably that you see the topic of discussion mostly from a practical point of view, which is all that is needed for the purposes of match-letrec, of course. My interest is probably more of a theoretical nature. Given Petrowsky's trick, I have been looking for loopholes (which all would have to be closed to make it viable). Scheme is not only a practical language but also a tool for programming language study.