3 ms·
It would be a service to non-Lisp users if someone could describe why this matters. Is this debug pretty-printing?
by KerrAvon 2y ago
It would be a service to non-Lisp users if someone could describe why this matters. Is this debug pretty-printing?
- db48x 2y agoFrom the webpage: > `trivial-inspect` exposes a set of utils useful in building inspectors akin to standard `inspect` and `describe`. Here is the documentation for `inspect`, <https://www.lispworks.com/documentation/HyperSpec/Body/f_inspec.htm#inspect https://www.lispworks.com/documentation/HyperSpec/Body/f_ins...> and `describe`, <https://www.lispworks.com/documentation/HyperSpec/Body/f_descri.htm#describe https://www.lispworks.com/documentation/HyperSpec/Body/f_des...>. I’ll quote the relevant bits here. First `describe`: > `describe` displays information about object to stream. > For example, `describe` of a symbol might show the symbol's value, its definition, and each of its properties. `describe` of a float might show the number's internal representation in a way that is useful for tracking down round-off errors. In all cases, however, the nature and format of the output of `describe` is implementation-dependent. > `describe` can describe something that it finds inside the object; in such cases, a notational device such as increased indentation or positioning in a table is typically used in order to visually distinguish such recursive descriptions from descriptions of the argument object. And finally `inspect`: > `inspect` is an interactive version of `describe`. The nature of the interaction is implementation-dependent, but the purpose of `inspect` is to make it easy to wander through a data structure, examining and modifying parts of it. Essentially these are built–in methods of introspection. One particularly nice thing about them is that `describe` calls a generic function named `describe-object`. Because this is a generic function, you can add specialized methods to it for your own classes. This lets you customize the output to best suit your own needs.
- jlarocco 2y agoAdding to what db48x said, the CL standard dictates what goes into the "COMMON-LISP" package (abbreviated "CL"), but also allows implementation specific additions as long as they're put in their own packages. Over time the different implementations have added similar functionality but with different APIs and in different packages. The "trivial-" prefix is a naming convention for third party (not a compiler vendor) packages that wrap those implementation specific system libraries to provide the same API everywhere. Usually these are implemented as macros or functions simple enough to get inlined and not have much overhead. In this case, the standard only requires high level functions "inspect" and "describe", but most implementations have packages (SBCL provides a "sb-introspect") to get more detail. It's generally done for things like threading, garbage collection settings, CFFI, etc. that would be difficult to implement outside of the compiler or runtime.