On 27.06.23 14:07, Waldek Hebisch wrote:
Both Lisp version and the above behave rather badly when called
from command line (the same is true for parseAndEvalStr).
Namely, after calling it interpreter is apparently waiting
for more input from the string, but none is coming. So
command line is effectively blocked. Probably does not
matter for server style use, but definitely it is not "universal"
function.
Maybe I do not quite get what you say. Is it: "The function works nicely,
but the user cannot send another string during the time the first call to
interpret_block is running?" In other words I cannot have two instances of
interpret_block running at the same time?
I wonder how this could be ever relevant when FriCAS anyway uses just one
processor.
To explain more: interpret_block gets simple input and should do its
work in almost no time, but apparently it never finishes. I must
admit that natural question is how it can work at all in
webspad? I did not look but probably some of extra variable
setting causes it to finish.
Oh... that sounds scary. I never saw that my |interpret-block| lisp
function did not return, OK, only for long running processes that are
expected not to return.
BTW: To see what I mean try
s := "1 + 1"
interpret_block(s)$Lisp
Yes, I also see that with pure FriCAS and even loading the boot function
into a jfricas session and executing interpret_block(s)$Lisp never returns.
Hmmm, strange. But then I never call interpret-block directly in
webspad.lisp. In fact, it can have two reasons. One is this:
(defun |webspad-parseAndEvalStr| (code)
(setf |$printStorageIfTrue| T) ; Make sure we get "Storage:" line.
(setf |$fortranFormat| NIL) ; we don't want Fortran output
(setf |$htmlFormat| NIL) ; we don't want Html output
(setf |$openMathFormat| NIL) ; we don't want OpenMath output
(setf |$MARGIN| 0) ; we don't want indentation
(eq (catch 'SPAD_READER (catch '|top_level| (|interpret-block| code)))
'|restart|))
and if that is not sufficient to return, then webspad only calls that
function after having modified a number of streams.
https://github.com/fricas/jfricas/blob/master/jfricas/webspad.lisp#L155
I suspect that it is the last line in |webspad-parseAndEvalStr| that
saves me. Unfortunately, I were completely lost if I had to explain why
this line is there and what would happen if I removed it.
Although it would be an interesting idea to send and evaluate other input to
FriCAS during a long running command, but wouldn't that badly interfere with
session management? When the first command does something like "z:=1; for i
in 1..10^100 repeat print(i)" and the second one says "z:=2", would the
first one suddenly print 2?
Not a problem at all. Effectively this is done when you run
Hyperdoc examples.
But you maybe saying that hyperdoc runs in a different frame, so my
current session is actually not affected.
BTW, HyperDoc probably starts a completely new FriCAS process with no
assigned variables whatsoever. Or will it contact the running kernel and
just use a new frame?
Actually, my question is whether it would be possible to clone a running
fricas session and continue with some computation in one clone with at
the same time with another computation in another clone? Yes, I somehow
want to use the many processors on my machine and are always sad that I
must start two completely separate fricas sessions with only string
communication between them. Somehow more parallelism in FriCAS would be
wonderful... dream, dream.
Ralf
--
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/7c6569ad-c023-3e8e-0bf4-e9675f7d6942%40hemmecke.org.