'execute_lisp_function' seems right for the job and 'begin' looks like a good candidate for the actual function to call. But it sets "!*echo := not !*int" which is a bit inconvenient. So I wrote a simplified version of 'begin' which sets flags I want:I was trying get Reduce to process a bunch of expressions, so I was looking for a way to relatively easily access its algebraic mode from procedural interface (mainly because I don't want to parse them myself, which I would need if I stayed on lisp/symbolic side, but there are other nice things in algebraic mode too).I'd appreciate if you could find a minute to have a look at and possibly comment on my earlier questions (they are quoted at the end of this email for convenience). And I have a few more.
(de begin-batch nil
(fluid (quote (!*echo !*mode !*int)))
(global (quote (ifl!* ipl!* ofl!* crbuf!* !*extraecho)))
(setq ifl!* nil) (setq ipl!* nil) (setq ofl!* nil) (setq !*echo nil) (setq !*extraecho nil) (verbos nil)
(setq !*mode (quote algebraic))
(errorp (errorset (quote (begin1)) !*backtrace !*backtrace))
(setq crbuf!* nil)
(return nil)))It has some problems though. Firstly the "(while (errorp (errorset ..." part doesn't seem to catch any errors, especially stuff like "Undefined symbol", which causes segmentation faults. It seems that in regular Reduce this kind of errors are caught by C-code, is it possible at all to catch them using procedural interface?
Things like this:symbolic rubbish();would cause "Error undefined function" in Reduce, but will crash everything if it happens somewhere inside procedural call such as 'execute_lisp_function'.
Another smaller problem is that if input ends with (bye) then (setq crbuf!* nil) above will never be executed. I guess the simplest thing is to redefine 'bye and 'quit to do something less destructive like (return nil), but I wonder if it could cause some adverse side-effects somewhere else?
ValeryOn 6 April 2014 01:54, Valery Yundin <firstname.lastname@example.org>
First of all, I'm new to Reduce so some questions
may be naive and have been already discussed
I think that Reduce gets much less attention than it
deserves. There might be many reasons for this, like
people being scared away by lisp, but one of them
IMO is a bit messy build system and there is no
library to use in other projects.
I've noticed that there is a way to compile
something like a library in csl/new-embedded
sub-directory. I had to make a few changes to make
it compile, and got a few questions in the process.
I've managed to approximately identify what
-DEMBEDDED=1 does, please correct me if I'm wrong
1. Sets hard-coded stack limit to 2MB
2. Tweaks something in terminal input/output
3. Disables something related to dynamically
Could anyone give more details?
I started writing autoconf/automake build scripts to
compile a library similar to new-embedded but with
more flexibility. For that purpose it would be
useful to split EMBEDDED functionality into logical
subsets. For instance hard-coding stack limit might
be useful sometimes, but it is completely unrelated
to other things which EMBEDDED does (and which I
don't understand fully).
Also I noticed that profiling doesn't see to work
with EMBEDDED=1, I'm not sure why yet (might be
related to point 3?). It would be useful to be able
to compile optimized version of library, at the
moment my scripts can do it only with EMBEDDED not
I'm curious how much user interface is fused with
the backend in Reduce. In particular what kind of
inevitable limitations will a library with
everything except the UI have? Is it possible to
more cleanly separate interface from the core and
make it easier to create alternative UI? It seems
that now it is all glued with #ifdefs scattered
around and for instance --without-gui option seems
to be slightly broken (perhaps because developers
don't use it often).
Another thing is tests, some of them are not
producing reference output. Is it a known
problem/not a problem or have I done something
Do you think a mirror of the official SVN repository
on github.com (git interoperate with svn seamlessly)
would be useful? Also maybe a separate repository
with a cut-down minimal version which contains only
CSL and packages (without things likepackages/rubi_red/rubi4/IntegrationTestResults/MathematicaTestResults/Mathe
maticaNotebookFiles/) for people to get started