|Subject:||[Chicken-hackers] read/write invariance of #!|
|Date:||Sun, 23 Dec 2018 01:29:24 -0600|
|In Chicken 5, read/write invariance of symbols beginning with #! is violated. |
(with-output-to-string (lambda () (write (string->symbol "#!abc")))) read)
Error: invalid `#!' token: “abc"
(with-output-to-string (lambda () (write (string->symbol "#!")))) read)
Error: invalid `#!' token: “"
This causes a problem with chicken-doc, as there is a syntax entry called “#!” which is written out but cannot be read back in. In Chicken 4, this symbol is escaped when written out and reads back in fine.
This occurs because in Chicken 5, sym-is-readable? was changed:
Unfortunately this assertion is incorrect: not all #! style symbols are readable, only valid #! style symbols such as #!rest. Other symbols are rejected by the reader. Furthermore, certain strange combinations, such as “(#! (foo bar))” result in an unterminated list, no matter how many close parens are added. The latter is the issue I am hitting.
The fix is probably to explicitly test for valid tokens, which appear to be only: “optional”, “rest” and “key”. Probably “eof” is ok as well—not 100% sure. The reader, of course, already tests for these exact tokens, so the writer should too.
Alas, chicken-doc won’t work with Chicken 5 until this is fixed — I worked around the file locking bug in 5.0.0, but the writer bug is fatal.
|[Prev in Thread]||Current Thread||[Next in Thread]|