From: szymon
Subject: How to slurp data from pprint-dispatch-table?
Date: 
Message-ID: <cjjgdj$s9l$1@nemesis.news.tpi.pl>
I want to extract all entries in (default) pprint dispatch table
- both keys (lists?) and values (functions).

Please help. I have cmucl 19a.

Regards, Szymon.

From: szymon
Subject: Re: How to slurp data from pprint-dispatch-table?
Date: 
Message-ID: <cjjgdr$bj3$1@atlantis.news.tpi.pl>
szymon wrote:
> 
> I want to extract all entries in (default) pprint dispatch table
                                ^^^^
'from' pprint dispatch table
> - both keys (lists?) and values (functions).
> 
> Please help. I have cmucl 19a.
> 
> Regards, Szymon.
From: Steven M. Haflich
Subject: Re: How to slurp data from pprint-dispatch-table?
Date: 
Message-ID: <415E23DC.7080206@alum.mit.edu>
szymon wrote:

>> I want to extract all entries in (default) pprint dispatch table
> 
>                                ^^^^
> 'from' pprint dispatch table
> 
>> - both keys (lists?) and values (functions).
>>
>> Please help. I have cmucl 19a.

There may be a way to do this in any particular implementation -- you
can learn a lot in a quality CL implementation using inspect -- but
there is no portable way gto do this in ANSI CL.

This is unfortuate, since X3J13 concurred informally that it was
generally a bad idea to have places in the language that could be
set or customized but which could not be fully introspected.  It is
possible for example for portable code to determine the complete
structure of package interdependence and inheritance, so that the
structure could be reconstructed afresh, but it is not possible
for portable code to extract enough information from a
pprint-dispatch table to reconstruct an equivalent table.  By the
way, the same limitation is true about readtables.
From: szymon
Subject: Re: How to slurp data from pprint-dispatch-table?
Date: 
Message-ID: <cjlscp$oic$1@nemesis.news.tpi.pl>
Steven M. Haflich wrote:
> szymon wrote:
> 
>>> I want to extract all entries from (default) pprint dispatch table
> [.....]
> There may be a way to do this in any particular implementation -- you
> can learn a lot in a quality CL implementation using inspect -- but
> there is no portable way gto do this in ANSI CL.
> [.....]

INSPECT helps. Thank you.

Regards, Szymon.
From: Raymond Toy
Subject: Re: How to slurp data from pprint-dispatch-table?
Date: 
Message-ID: <sxdfz4ufusw.fsf@edgedsp4.rtp.ericsson.se>
>>>>> "szymon" == szymon  <···@none.org> writes:

    szymon> Steven M. Haflich wrote:
    >> szymon wrote:
    >> 
    >>>> I want to extract all entries from (default) pprint dispatch table
    >> [.....]
    >> There may be a way to do this in any particular implementation -- you
    >> can learn a lot in a quality CL implementation using inspect -- but
    >> there is no portable way gto do this in ANSI CL.
    >> [.....]

    szymon> INSPECT helps. Thank you.

Looking at the code in pprint.lisp will probably help a lot too.  It
seems the pprint-dispatch-table is a structure with 2 slots: entries
and cons-entries.  Each of those contains pprint-dispatch-entry object
describing the entry.

    (pp::pprint-dispatch-table-entries *print-pprint-dispatch*) =>
    (#<PRETTY-PRINT::PPRINT-DISPATCH-ENTRY Type=ARRAY, priority=0 [Initial]>
     #<PRETTY-PRINT::PPRINT-DISPATCH-ENTRY
       Type=(CONS (AND SYMBOL (SATISFIES FBOUNDP))), priority=-1 [Initial]>
     #<PRETTY-PRINT::PPRINT-DISPATCH-ENTRY Type=CONS, priority=-2 [Initial]>)

    (maphash #'(lambda (k v) (format t "~a -> ~a~%" k v))
                      (pp::pprint-dispatch-table-cons-entries *print-pprint-dispatch*))

    LAMBDA -> #<PPRINT-DISPATCH-ENTRY
                Type=(CONS (EQL LAMBDA)), priority=0 [Initial]>
    BLOCK -> #<PPRINT-DISPATCH-ENTRY
               Type=(CONS (EQL BLOCK)), priority=0 [Initial]>
    CATCH -> #<PPRINT-DISPATCH-ENTRY
               Type=(CONS (EQL CATCH)), priority=0 [Initial]>
    COMPILER-LET -> #<PPRINT-DISPATCH-ENTRY
                      Type=(CONS (EQL COMPILER-LET)), priority=0 [Initial]>

etc.


Ray
From: Szymon
Subject: Re: How to slurp data from pprint-dispatch-table?
Date: 
Message-ID: <87ekka19pv.fsf@eva.rplacd.net>
Raymond Toy <···········@ericsson.com> writes:

> [....]
> Looking at the code in pprint.lisp will probably help a lot too.
> [....]

Good idea. Thank you. Btw, I slurp Richard C. Water's XP
pretty-printer.

Regards, Szymon.