On Wed, Dec 13, 2023 at 07:44:16PM +0800, Qian Yun wrote:
> Now I have a series of 7 patches, hopefully to solve this problem.
> 
> You can view them in attachment or at
> https://github.com/oldk1331/fricas/commits/stats
> 
> I'm not very sure about
> "reinit stats global variables when error happens".
> 
> Is "int_loop" the right place to reset $timedNameStack
> when error happens? (e.g. "1/0").

The code looks mostly good.  But concerning reseting $timedNameStack
I am not sure what to do.  Typical pattern in interpreter is
use of Lisp dynamic variables.  When something THROW-s, then
dynamic variables are automatically restored to value they had
at outer level.  Reseting in different way is problematic,
in principle every place containing CATCH must be checked if
it is doing correct thing, that is restores varibles before
wrong value is in use.  There is extra complication: in Spad
code we have no way do do dynamic binding, so Spad has
"try ... finally ..." construct which ensures that cleanup
code is run even in case of abnormal exit (that is THROW).
This construct translates to Lisp UNWIND-PROTECT (via
'finally' macro), and in principle UNWIND-PROTECT (or
'finally' macro) could be used to implement cleanup also
at BOOT level.

Anyway, given interpreter => algebra(Spad) => interpeter
chain, THROW from inner interpreter may be intercepted by
in algebra and return to outer interpeter.  So there is
need for cleanup in 'interpret' so that return from
algebra call have consistent state.

Remark: calls from algebra to interpeter are rare and
probablity that somebody will time them is low.  But it
is better to write correct code, than to bet that nobody
will see bugs.

BTW: AFAICS first patch and the last one are somewhat independent,
but to other seem to be tightly related, so it looks
unnatural to split this part into 5 patches.

-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/ZX5S9AFyYv9szx4z%40fricas.org.

Reply via email to