[cdr-discuss] [RfC] Issue: INSPECTOR-HOOK

Tobias C. Rittweiler tcr at freebits.de
Thu Mar 20 01:12:46 UTC 2008


Request for comments (this includes stylistic / spelling corrections)

  -T.


Status:       Draft

Forum:        Common Lisp Document Repository (CDR)

Issue:        INSPECTOR-HOOK

References:   INSPECT (function), *DEBUGGER-HOOK* (variable)

Category:     Addition

Edit History: 20-Mar-2008 by Rittweiler (Draft)


Problem Description:

  Cross-implementation Lisp programming environments such as SLIME or Climacs
  face the problem that the ANSI Common Lisp standard does not specify any way
  to hook into the inspection machinery of an implementation. Specifically,
  there is no portable way to install an inspector that is run when the function
  INSPECT is invoked.

Proposal (INSPECTOR-HOOK:*INSPECTOR-HOOK*-VARIABLE)

  Add a variable:

    
     *INSPECTOR-HOOK*                                         [VARIABLE]

     Value Type: 

     A designator for a function of one argument (the object to be
     inspected), or NIL.

     Initial Value: 

     NIL.

     Description:

     When the value of *INSPECTOR-HOOK* is non-NIL, an invocation of
     INSPECT in the dynamic-extent of this variable results in calling
     the value with the object that was originally passed to INSPECT.
    
     *INSPECTOR-HOOK* is not rebound before calling the function denoted
     by the value, i.e. it's bound to the same value as at the
     invocation of INSPECT; this is to allow inspectors to be defined
     recursively.

     The return value of INSPECT is independent of the return value of
     the denoted function, and remains implementation-dependent.

     Affected By:

     INSPECT

     See Also:

     *DEBUGGER-HOOK*

     Notes:

     It's possible to invoke the implementation's inspection machinery
     from within *INSPECTOR-HOOK* by binding it to NIL before invoking
     INSPECT.

Rationale:

  This proposal was closely modelled on the specification of *DEBUGGER-HOOK*,
  and allows programs to install their own inspectors that are adapted
  to their respective domains.

Notes:

  The proposal does deliberately say nothing about the home-package of the
  symbol *INSPECTOR-HOOK*. However, implementors are encouraged to export this
  symbol from their extensions package (often called "EXT") or another
  appropriate package---unless a later CDR document specifies a more explicit
  location.

Current Practise:

  On at least SBCL, Clisp, and Clozure CL, it's possible to straightforwardly
  hook into their inspection machinery, albeit by mostly unexported and
  undocumented means.

  The documentation of Franz' Allegro CL states that an invocation of INSPECT
  runs a GUI inspector on the MS Windows operating system, and a text-based
  inspector on other operating systems, so it's very likely that they employ
  some hook mechanism internally.

Cost to implementators:

  Negligible.

Cost to user:

  None. The proposal is fully upward compatible.

Cost of Non-Adoption:

  The problem, as described above, remains.

Benefits:

  Slightly more powerful / convenient Lisp programming environments.

Aesthetics:

  Inhibits the necessity to rely on implementation-dependent cruft.




More information about the cdr-discuss mailing list