💾 Archived View for shaggypeak.com › library › r7rs › section2.4.gmi captured on 2023-03-20 at 19:53:36. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
#⟨n⟩=⟨datum⟩ lexical syntax #⟨n⟩# lexical syntax
The lexical syntax #⟨n⟩=⟨datum⟩ reads the same as ⟨datum⟩, but also results in ⟨datum⟩ being labelled by ⟨n⟩. It is an error if ⟨n⟩ is not a sequence of digits.
The lexical syntax #⟨n⟩# serves as a reference to some object labelled by #⟨n⟩=; the result is the same object as the #⟨n⟩= (see section 6.1).
Together, these syntaxes permit the notation of structures with shared or circular substructure.
(let ((x (list ’a ’b ’c))) (set-cdr! (cddr x) x) x) =⇒ #0=(a b c . #0#)
The scope of a datum label is the portion of the outermost datum in which it appears that is to the right of the label. Consequently, a reference #⟨n⟩# can occur only after a label #⟨n⟩=; it is an error to attempt a forward reference. In addition, it is an error if the reference appears as the labelled object itself (as in #⟨n⟩= #⟨n⟩#), because the object labelled by #⟨n⟩= is not well defined in this case.
It is an error for a ⟨program⟩ or ⟨library⟩ to include circular references except in literals. In particular, it is an error for quasiquote (section 4.2.8) to contain them.
#1=(begin (display #\x) #1#) =⇒ error