Re: Wow, Lisp Reader !!

"Jon Boone (as ipmonger at delamancha dot org)" <[email protected]> Sat, 23 May 2026 18:00:01 -0400
Newsgroups gmane.lisp.lispworks.general
Message-ID <CACdCdGhK9oJjiupg_fp0+hXstBEVjz1yUbJsg9GSgRkOR3FJpg@mail.gmail.com>
Would either of these approaches possibly work?

   1. Like '$math_expr$' in LaTeX triggers in-line math-mode, you can
   create a macro-key sequence that switches to your custom Readtable just for
   that format and have the macro evaluate the input to generate the proper
   character sequence for normal Readtable usage, or
   2. I think you can create a custom macro-key in the default Readtable
   that lets you type your preferred syntax. This macro would un-read the
   previous symbols with the ':' delimiters and re-format them into output
   compatible with the normal read-table.


—jon


On Sat, May 23, 2026 at 5:41 PM David McClain (as dbm at
refined-audiometrics dot com) <[email protected]> wrote:

> Holy smokes… Common Lisp did such an amazing job with everything else, and
> especially CLOS. But now that I am old, I want to specialize the Lisp
> Reader for myself. I get really wearing not being able to enter DD:MM:SS
> for Right Ascensions and Declinations.
>
> But gobsmack'ingly, the Common Lisp Reader is hugely resistant to
> customization. The HyperSpec hints that custom readers should be possible:
>
> 2.1.4 Character Syntax Types
>
> The *Lisp reader*
> <https://www.lispworks.com/documentation/HyperSpec/Body/26_glo_l.htm#lisp_reader> constructs
> an *object*
> <https://www.lispworks.com/documentation/HyperSpec/Body/26_glo_o.htm#object> from
> the input text by interpreting each *character*
> <https://www.lispworks.com/documentation/HyperSpec/Body/26_glo_c.htm#character> according
> to its *syntax type*
> <https://www.lispworks.com/documentation/HyperSpec/Body/26_glo_s.htm#syntax_type>.
> The *Lisp reader*
> <https://www.lispworks.com/documentation/HyperSpec/Body/26_glo_l.htm#lisp_reader> cannot
> accept as input everything that the *Lisp printer*
> <https://www.lispworks.com/documentation/HyperSpec/Body/26_glo_l.htm#lisp_printer> produces,
> and the *Lisp reader*
> <https://www.lispworks.com/documentation/HyperSpec/Body/26_glo_l.htm#lisp_reader> has
> features that are not used by the *Lisp printer*
> <https://www.lispworks.com/documentation/HyperSpec/Body/26_glo_l.htm#lisp_printer>.
> *The Lisp reader
> <https://www.lispworks.com/documentation/HyperSpec/Body/26_glo_l.htm#lisp_reader> can
> be used as a lexical analyzer for a more general user-written parser.*
>
>
> And yet, there are no functions to allow interrogation of the Readtable
> for character syntax types corresponding to any particular character,
> except for those that are marked as macro characters.
>
> Other, macro characters, like tic (apostrophe) #\’ should really only
> carry meaning at the leading edge of a symbol name. But it serves as a
> stopping delimiter in the Lisp Reader so that you cannot have symbol names
> like Thing and Thing’, without writing them as |Thing’|.
>
> Interestingly, the colon character, #\:, which is used to separate package
> names from symbol names, is *NOT* shown as anything special in the
> HyperSpec. It is simply listed as a constituent character.
>
> Maddeningly, LW chose to intercept this character with eager resolution,
> rather than allowing it to just become absorbed as a compound symbol token
> for later analysis. And there are no CL Hooks to be found that allows for
> alternate interpretations.
>
> So I find it totally mystifying that this corner of Common Lisp should be
> so comparatively backwards.
>
>
> [ I apologize if I come off too harsh. I cut my teeth on Forth, which has
> no restrictions, at the observatories many decades ago… ]
>