Re: Wow, Lisp Reader !!
"Pascal Bourguignon (as informatimago at gmail dot com)" <[email protected]> Sun, 24 May 2026 16:56:13 +0200
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <CAHba7sHg7GzbBysv6Pi4DbqcoNtpd-ewyBjfEgPy61iQGSOv0Q@mail.gmail.com> |
It’s white spaces and any terminating macro (or dispatching) macro character. And this can be queried with gat-macro-character So for example (foo’bar) has two elements but (foo#bar) has only one while (foo #p "bar") has two. There is a list of white space in the standard-character set (you can extend it with Unicode), and query the read table for the other terminating macro characters. See (map nil 'print (com.informatimago.tools.reader-macro:list-all-macro-characters)) In https://github.com/informatimago/lisp/blob/master/tools/reader-macro.lisp -- __Pascal Bourguignon__ +33623171770 [email protected] Le dim. 24 mai 2026 à 16:33, David McClain <[email protected]> a écrit : > Point of curiosity… > > I see that the Lisp community has chosen to allow not only whitespace, but > also parentheses, as parse stopping point. Totally reasonable, given the > basis of the language in Sexprs. But why also Quote, Backquote? Also > Semicolon - seems reasonable. Comma and Vertical Bar? > > I can easily envision wanting symbol names ending in a quote, as in X’ > (for x-prime). > > > On May 24, 2026, at 07:14, David McClain (as dbm at refined-audiometrics > dot com) <[email protected]> wrote: > > > > On May 24, 2026, at 02:29, Pascal Bourguignon <[email protected]> > wrote: > > (defun install-angle-reader (&optional (readtable *readtable*)) > "Install the angle reader macro on digits and signs." > (dolist (c '(#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\+ #\-)) ; <- the > magic is here ;-) > (set-macro-character c #'read-angle-or-fallback t readtable)) > readtable) > > > > Now this is interesting, but it also illustrates the control point I just > described. As long as you are inside a Reader Macro, you have absolute > control. Pascal has exerted the control on individual digit chars. That > seems a brilliant way to approach things! > > Your point about prefix mapping the parser might be theoretically valid, > i.e., first two chars determines the route. But in practice, LW Reader also > uses the special chars for stopping parses. That is to say that a Quote > will stop an ongoing number parse, unless you preemptively take control > through a reader macro doing READ-CHAR. Depending on the Reader at the READ > level will fail your intentions. > > >