On Wed, May 20, 2026 at 12:05:29PM +0800, Qian Yun wrote:
> On 5/16/26 9:29 PM, Waldek Hebisch wrote:
> > On Sat, May 16, 2026 at 09:14:15PM +0800, Qian Yun wrote:
> >> If you do something like "sin(x) pretend SExpression",
> >> it will take a long time.
> >>
> >> This is useful during debugging.
> >>
> >> After this patch, the output is still unreadable, but much faster.
> >
> > I admit that I find Lisp level printouts of some kinds of FriCAS
> > data useless. Basically, this is when types are part of data
> > structure (in particular representation of functions typically
> > contains type). It is not clear to me if speeding up such
> > useless printouts is worthwile. OTOH without '*print-pretty*'
> > even otherwise simple printouts are much harder to read.
> >
>
> Speedup this printout of Kernel is to ease the pain during
> debugging EXPR.
>
> We can get much more compact printout, if we only print the
> name of "operator" instead of its full property list.
>
> But this will break write!$File. (See src/input/files.input,
> write a EXPR into a file and read it back.)
> (BTW, is this serialization/de-serialization process
> reliable for EXPR?)
It is hard to exclude possibility of bugs, but a lot of effort
went into making this reliable and currently I am not aware
of bugs there. The whole reason for SPAD_KERNEL is to allow
serialization/deserialization at level of Lisp representation.
To ensure uniqeness of kernels, kernels must have nonzero
position only when they are present in the cache. That is
why they are written out withithout position and on reading
position set to 0. After that Kernel code will notice that
position is 0 and enter the kernel into the cache.
> How about setting a Lisp variable in File domain,
> and if the Kernel's :print-function detects that, print
> full version; otherwise print the short version.
That looks potentially bug-prone. I admit that I would
prefer Spad specific debugging functions. Note that problem
is really not about kernels but about types: Spad types are
rather bulky as Lisp data structures and a lot of Spad data
contains types. AFAICS bulk is cause by '%diff' and
'%eval' properties of 'sin'. Values of both are Spad
funtions and type is part of function representation:
Spad function is represented as a pair, first element of
the pair is Lisp function, the second is data which
typically is domain vector corresponding to the type.
Note that you will get the same problem trying to
print Spad functions or trying to trace Spad functions
using Lisp 'trace'.
--
Waldek Hebisch