Ralf Hemmecke wrote:
>
> The most burning questions from my part would be.
>
> 1) How would I go to add the ZeroMQ library to FriCAS so that I could
> use its functionality from Lisp (or even better from BOOT or even SPAD).
1) You need to either link or dynamically load the library.
Currently with sbcl, clisp and openmcl only option is dynamic linking.
With ecl and gcl both are possible, but static linking works
better. Theoretically w could use static linking with clisp,
but this looks quite hard to automate. Anyway, look like
'libspad' is handled. You need to write code to dynamically load
the library for Lisp that use dynamic linking and adjust
Makefiles to link it statically in other cases. This
assumes that you have both static and dynamic version
of the library. If you have only static one than you are
out of luck: you can only use Lisps that use static
linking. If you have only dynamic version you may create
a small static library with wrappers calling real
functions in dynamic library. Then you statically link
wrappers and linker/OS takes care of dynamic library.
Once you have linked library to FriCAS image you need
to make available its functions to FriCAS
2) Look at types of arguments/return values. If you have simple
types than existing macros in src/lisp/fricas-lisp.lisp should
work. You use them like:
(fricas-foreign-call |writeablep| "writeablep" int
(filename c-string))
First is Lisp name you want, than C name, return type
and pairs (argument name, argument type). Once you
have Lisp function you can freely use it from Boot and Spad
(in Spad via $Lisp). To get typechecking it is good to write
wrappers in Spad with appropriate types.
Note: this is generic instruction about adding foreign library.
You may look at Lapack thread to get more information.
Note2: After that you will be able to call ZeroMQ functions,
but it does not mean that this will bring you any closer
to your goal. AFAICS to work well within existing framework
you should call ZeroMQ functions from our C code
>
> 2) In my previous mail I talked about TERPRI and PRINTEXP.
> Unfortunately, this all seems to be related to a (hidden) variable
> $fricasOutput. Is there somewhere some documentation that would help me
> to understand how currently the output is done (with all its redirections)?
Sorry, it is a mess. Part of it is inherited. Part is new mess
which replaced old one -- I feel that new mess is a bit less
messy than old one, but not much. Basically, I would like
to get rid of all redirections -- that requires to have
explicit stream arguments from top down to lowest level.
Original code worked redirecting standard Lisp streams.
'$fricasOutput' is an attempt to eliminate redirection
of standard Lisp streams, but is not finished.
I do not expect redirections to be documented: once part
of it is understood well enough it can be safely removed.
>
> 3) Do you think it would be enough to figure out about all uses of
> TERPRI/PRINTEXP and replace them by a central lisp abstraction so that
> output through ZeroMQ could be hooked up there?
There is bunch of other functions that do output -- potentially
about 20. It would be good to sort this out, but ATM do
not count on me doing this: IME such work requres some
interval of time (optimistically a week) where attension is
focused on this task. It is hard to spare such continuous
interval, and even if I had one there are tasks of higerer
priority.
>
> 4) I certainly only want to modify interactive user input and redirect
> that over ZeroMQ. How can I distinguish whether (for example), input
> currently comes from a file or from a pipe to stdin? The latter is not
> interactive and should, of course not go through ZeroMQ.
You probably should not make such distinction. There are input
streams and when you _create_ stream you should know its destination
and conseqently which transport to use. Once stream is created
you should not care. More precisely, user input goes via
'serverReadLine'. If you want to support multiple input
sources than you need to hook into 'serverSwitch' (which
is really C code). File reading is separate, so do not
worry about it.
You may have more trouble with output: all output goes
together and 'session' is responsible for multiplexing it
to right destination.
However you wrote that you do not want to support multiple
input sources. This in particular means no pipes (and
as I wrote files are handled separately) and no need
to multiplex output.
--
Waldek Hebisch
heb...@math.uni.wroc.pl