Re: Wow, Lisp Reader !!
"David McClain (as dbm at refined-audiometrics dot com)" <[email protected]> Sun, 24 May 2026 07:07:29 -0700
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
> On May 24, 2026, at 01:56, Tim Bradshaw (as tfb at cley dot com) <[email protected]> wrote: > > I'm guessing that the reason it's all so opaque is that the reader only has to behave as if the things the spec describes are true: it might internally be doing something quite different, especially for interactive use. Exposing more of it would tend to force it to actually behave the way it's meant to, which would constrain implementations a lot more. > You are exactly correct, according to what all my efforts revealed… Hence my initial expression of disappointment with the design of the CL Reader, in contrast to the superb design of CLOS. What happened? Perhaps the Standards Committee ran out of gas (time, patience, and money). I really can accomplish what I want. I have done it before. But it requires dissecting the LW Reader system and modifying undisclosed portions. I did that once already. It still works (mostly) for LW. But it recently broke badly in SBCL when I discovered from the source code that the entire Reader system had been re-engineered and changed completely. And this is likely to happen again and again. So I was trying, once again, to paint within the lines and look for a portable way to accomplish what I could. Turns out that Reader Macros are your only point of documented control. Once you land inside one of those, you are in control of reading every next character, if you choose to do so. And you have control of errors that happen within your reader macro. But trying to use HANDLER-BIND against the outer READ and READ-PRESERVING-WHITESPACE is pointless when the underlying system does not recursively depend on them. Then, in that case, the HANDLER-BIND is working at too coarse a level. Any error deep within the Reader system gets vectored to a control point too distant, and then provides an incomplete answer. You might have been in the midst of reading a list of items, get Handled on one of the items, then provide a recovery answer that supplies the one element, and ends of dropping the outer context of multiple items. There is a limit to the precision of the scalpel of the Lisp Exception system. You need to have architected the restart and handling points along the way. And you need a mechanism for modular replacement (e.g., CLOS). - DM