Previous: Documentation and Comments, Up: Lexical Conventions


4.8.4 Modifying Read Syntax

— Callback procedure: read:sharp c port

If a <#> followed by a character (for a non-standard syntax) is encountered by read, read will call the value of the symbol read:sharp with arguments the character and the port being read from. The value returned by this function will be the value of read for this expression unless the function returns #<unspecified> in which case the expression will be treated as whitespace. #<unspecified> is the value returned by the expression (if #f #f). — Callback procedure: load:sharp c port

Dispatches like read:sharp, but only during loads. The read-syntaxes handled by load:sharp are a superset of those handled by read:sharp. load:sharp calls read:sharp if none of its syntaxes match c.

— Callback procedure: char:sharp token

If the sequence <#\> followed by a non-standard character name is encountered by read, read will call the value of the symbol char:sharp with the token (a string of length at least two) as argument. If the value returned is a character, then that will be the value of read for this expression, otherwise an error will be signaled.

Note When adding new <#> syntaxes, have your code save the previous value of load:sharp, read:sharp, or char:sharp when defining it. Call this saved value if an invocation's syntax is not recognized. This will allow #+, #-, and Uniform Arrays to still be supported (as they dispatch from read:sharp).