A portable Common Lisp toolkit for building inspectors

https://github.com/aartaka/trivial-inspect

trivial-inspect

A portable toolkit for building inspectors

trivial-inspect exposes a set of utils useful in building inspectors akin to standard inspect and describe. The goal is to provide as much information as possible. Including the implementation-specific info.

Getting Started

Clone the Git repository:

git clone --recursive https://github.com/aartaka/trivial-inspect ~/common-lisp/

And then load :trivial-inspect in the REPL:

(asdf:load-system :trivial-inspect)
;; or, if you use Quicklisp
(ql:quickload :trivial-inspect)

You can also use the bundled guix.scm to install it on Guix.

APIs

Two main entry points of this library are fields:

(trivial-inspect:fields #'identity)
;; ((0 :self #<function identity>) (1 :id 1407351035)
;;  (2 class-of #<sb-pcl:system-class common-lisp:function> #<function # {100A28547B}>)
;;  (3 type-of compiled-function) (4 :name identity) (5 :arguments (sb-impl::thing))
;;  (6 compiled-function-p t) (7 :ftype (function # #))
;;  (8 :expression nil)
;;  (9 lambda-list-keywords (&allow-other-keys &aux &body &environment &key sb-int:&more &optional &rest &whole))
;;  (10 call-arguments-limit 1073741824) (11 lambda-parameters-limit 1073741824))
(trivial-inspect:fields nil)
;; ((0 :self nil) (1 :id 1342177559)
;;  (2 class-of #<built-in-class common-lisp:null> nil)
;;  (3 type-of null) (4 length 0)
;;  (5 symbol-name "NIL") (6 symbol-package #<package "COMMON-LISP">)
;;  (7 :visibility :external #<function # {100CFF5F0B}>)
;;  (8 symbol-value nil #<function # {100CFF5F2B}>) (9 symbol-plist nil))
(trivial-inspect:fields (find-class 'standard-object))
;; ((0 :self #<standard-class common-lisp:standard-object>) (1 :id 68721940739)
;;  (2 class-of #<standard-class common-lisp:standard-class>
;;   #<function (lambda (trivial-inspect::new-value trivial-inspect::_) :in trivial-inspect:fields) {1003A7BAEB}>)
;;  (3 :slot-definitions
;;   (#<sb-mop:standard-effective-slot-definition sb-pcl::%type> #<sb-mop:standard-effective-slot-definition sb-pcl::source> ..)))

and description:

(trivial-inspect:description #'+ t)
;; Compiled-function + (&REST NUMBERS)
;;  : (&REST NUMBER) -> (VALUES NUMBER &OPTIONAL)
;; Return the sum of its arguments. With no args, returns 0.
(trivial-inspect:description 'standard-class t)
;; Symbol STANDARD-CLASS (EXTERNAL to COMMON-LISP) [class]
(trivial-inspect:description (find-class 'standard-class) t)
;; Standard-class #<STANDARD-CLASS COMMON-LISP:STANDARD-CLASS>
{
"by": "anonzzzies",
"descendants": 19,
"id": 40246185,
"kids": [
40250445,
40252023,
40257030,
40260592,
40253598,
40253246
],
"score": 57,
"time": 1714733030,
"title": "A portable Common Lisp toolkit for building inspectors",
"type": "story",
"url": "https://github.com/aartaka/trivial-inspect"
}
{
"author": "aartaka",
"date": null,
"description": "A portable Common Lisp toolkit for building inspectors - aartaka/trivial-inspect",
"image": "https://opengraph.githubassets.com/aece5d380f016204ed32d1fa03d345aad1be5d54776f550c381a0736c664cdd4/aartaka/trivial-inspect",
"logo": "https://logo.clearbit.com/github.com",
"publisher": "GitHub",
"title": "GitHub - aartaka/trivial-inspect: A portable Common Lisp toolkit for building inspectors",
"url": "https://github.com/aartaka/trivial-inspect"
}
{
"url": "https://github.com/aartaka/trivial-inspect",
"title": "GitHub - aartaka/trivial-inspect: A portable Common Lisp toolkit for building inspectors",
"description": "trivial-inspect A portable toolkit for building inspectors trivial-inspect exposes a set of utils useful in building inspectors akin to standard inspect and describe. The goal is to provide as much...",
"links": [
"https://github.com/aartaka/trivial-inspect"
],
"image": "https://opengraph.githubassets.com/aece5d380f016204ed32d1fa03d345aad1be5d54776f550c381a0736c664cdd4/aartaka/trivial-inspect",
"content": "<div><article><p></p><h2>trivial-inspect</h2><a target=\"_blank\" href=\"https://github.com/aartaka/trivial-inspect#trivial-inspect\"></a><p></p>\n<p><b>A portable toolkit for building inspectors</b></p>\n<p><code>trivial-inspect</code> exposes a set of utils useful in building inspectors\n akin to standard <code>inspect</code> and <code>describe</code>. The goal is to provide as\n much information as possible. Including the implementation-specific\n info.</p>\n<p></p><h2>Getting Started</h2><a target=\"_blank\" href=\"https://github.com/aartaka/trivial-inspect#getting-started\"></a><p></p>\n<p>Clone the Git repository:</p>\n<div><pre>git clone --recursive https://github.com/aartaka/trivial-inspect <span>~</span>/common-lisp/</pre></div>\n<p>And then load <code>:trivial-inspect</code> in the REPL:</p>\n<div><pre>(<span>asdf</span>:load-system <span>:trivial-inspect</span>)\n<span><span>;</span>; or, if you use Quicklisp</span>\n(<span>ql</span>:quickload <span>:trivial-inspect</span>)</pre></div>\n<p>You can also use the bundled <code>guix.scm</code> to install it on Guix.</p>\n<p></p><h2>APIs</h2><a target=\"_blank\" href=\"https://github.com/aartaka/trivial-inspect#apis\"></a><p></p>\n<p>Two main entry points of this library are <code>fields</code>:</p>\n<div><pre>(<span>trivial-inspect</span>:fields <span>#'</span><span>identity</span>)\n<span><span>;</span>; ((0 :self #&lt;function identity&gt;) (1 :id 1407351035)</span>\n<span><span>;</span>; (2 class-of #&lt;sb-pcl:system-class common-lisp:function&gt; #&lt;function # {100A28547B}&gt;)</span>\n<span><span>;</span>; (3 type-of compiled-function) (4 :name identity) (5 :arguments (sb-impl::thing))</span>\n<span><span>;</span>; (6 compiled-function-p t) (7 :ftype (function # #))</span>\n<span><span>;</span>; (8 :expression nil)</span>\n<span><span>;</span>; (9 lambda-list-keywords (&amp;allow-other-keys &amp;aux &amp;body &amp;environment &amp;key sb-int:&amp;more &amp;optional &amp;rest &amp;whole))</span>\n<span><span>;</span>; (10 call-arguments-limit 1073741824) (11 lambda-parameters-limit 1073741824))</span>\n(<span>trivial-inspect</span>:fields <span>nil</span>)\n<span><span>;</span>; ((0 :self nil) (1 :id 1342177559)</span>\n<span><span>;</span>; (2 class-of #&lt;built-in-class common-lisp:null&gt; nil)</span>\n<span><span>;</span>; (3 type-of null) (4 length 0)</span>\n<span><span>;</span>; (5 symbol-name \"NIL\") (6 symbol-package #&lt;package \"COMMON-LISP\"&gt;)</span>\n<span><span>;</span>; (7 :visibility :external #&lt;function # {100CFF5F0B}&gt;)</span>\n<span><span>;</span>; (8 symbol-value nil #&lt;function # {100CFF5F2B}&gt;) (9 symbol-plist nil))</span>\n(<span>trivial-inspect</span>:fields (<span>find-class</span> <span>'</span>standard-object))\n<span><span>;</span>; ((0 :self #&lt;standard-class common-lisp:standard-object&gt;) (1 :id 68721940739)</span>\n<span><span>;</span>; (2 class-of #&lt;standard-class common-lisp:standard-class&gt;</span>\n<span><span>;</span>; #&lt;function (lambda (trivial-inspect::new-value trivial-inspect::_) :in trivial-inspect:fields) {1003A7BAEB}&gt;)</span>\n<span><span>;</span>; (3 :slot-definitions</span>\n<span><span>;</span>; (#&lt;sb-mop:standard-effective-slot-definition sb-pcl::%type&gt; #&lt;sb-mop:standard-effective-slot-definition sb-pcl::source&gt; ..)))</span></pre></div>\n<p>and <code>description</code>:</p>\n<div><pre>(<span>trivial-inspect</span>:description <span>#'</span><span>+</span> <span>t</span>)\n<span><span>;</span>; Compiled-function + (&amp;REST NUMBERS)</span>\n<span><span>;</span>; : (&amp;REST NUMBER) -&gt; (VALUES NUMBER &amp;OPTIONAL)</span>\n<span><span>;</span>; Return the sum of its arguments. With no args, returns 0.</span>\n(<span>trivial-inspect</span>:description <span>'</span>standard-class <span>t</span>)\n<span><span>;</span>; Symbol STANDARD-CLASS (EXTERNAL to COMMON-LISP) [class]</span>\n(<span>trivial-inspect</span>:description (<span>find-class</span> <span>'</span>standard-class) <span>t</span>)\n<span><span>;</span>; Standard-class #&lt;STANDARD-CLASS COMMON-LISP:STANDARD-CLASS&gt;</span></pre></div>\n</article></div>",
"author": "",
"favicon": "https://github.githubassets.com/favicons/favicon.svg",
"source": "github.com",
"published": "",
"ttr": 55,
"type": "object"
}