On Mon, Dec 18, 2023 at 06:18:20PM +0800, Qian Yun wrote:
> 
> 
> On 12/18/23 08:56, Waldek Hebisch wrote:
> > 
> > > > > How about let's proceed like this:
> > > > > 
> > > > > 1. apply the patch in this mail, to prevent infinity recursion
> > > > 
> > > > I am affraid that we need to do something in 'interpMap' in 
> > > > (i-map.boot).
> > > > 
> > > 
> > > So the dynamic variable shadowing should also happen in "interpret1"?
> > > 
> > > BTW, can you give an example of "interpOnly"?  So that I can test it.
> > 
> > Interpreter uses somewhat funky data structures, so it is hard to make
> > a separate call.  "interpOnly" is called when interpreter fails to compile
> > a function, basically when it does not see that types match.
> > There is a message:
> > 
> > FriCAS will attempt to step through and interpret the code.
> > 
> > you can use it to search for examples.
> > 
> 
> One such example of "interpOnly" is:
> 
>     f==n+->sum(sum(1/i,i=1..j),j=1..n)
>     f(1)
> 
> Back to this bug:
> 
> So it seems that "savedTimerStack" is intentionally paired with "CATCH".
> Given the nature of stack, I presume a simple assignment is enough, copy
> is not needed?
> 
>    savedTimerStack := $timedNameStack
>    c := CATCH('interpreter,interpret(x, posnForm))
>    $timedNameStack := savedTimerStack
> 
> Otherwise I'm a bit lost to this bug.

Well, original had:

  while savedTimerStack ^= $timedNameStack repeat
    stopTimingProcess peekTimedName()

'stopTimingProcess' calls 'updateTimedName' which was/is needed
to update counters.  IIUC without this statistics will be wrong
(time will be "charged" to different use).

> Waldek, what's your opinion on fixing this bug?

AFAICS loop here and in interpretTopLevel where right.  I am not
sure if the loop is really necessary, but we need to do proper
accounting and the loop is "obviously correct" way of doing this.
Another approach may easily get broken by changes.

IMO proper fix for this bug involves making sure that we always
have valid '$timedNameStack' and that it is in sync with other
variables.  One way to ensure this is doing "push" on init,
instead of assignment.

-- 
                              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/ZYDdTepVEocxyatI%40fricas.org.

Reply via email to