Serge D. Mechveliani wrote: > > > [..] > > OTOH it seems that code which simply writes and reads lines > > does not work due to bug in sbcl (in version used for release, > > seems to be fixed in newer versions). > > > > I use FriCAS 1.1.5 made from source with the option > --with-lisp=/usr/bin/clisp > in ./configure > on the Debian Linux system. > > And /usr/bin/clisp === GNU CLISP 2.48 (2009-07-28). > > Do you mean that FriCAS still has sbcl inside it? > Do I need to install sbcl and to build FriCAS under it? >
No, I thought that you are using released binary which is based on sbcl-1.0.22. Look at: http://www.math.uni.wroc.pl/~hebisch/fricas/fifoToAxiom.c and http://www.math.uni.wroc.pl/~hebisch/fricas/fifoToC.input When using clisp based FriCAS they "almost" work (there is message at the end: >> Error detected within library code: End of file but otherwise it seem be what you expect. > > > You are closing and opening pipes in each iteration. I did > > not analyse this in detail, but it looks like asking for > > trouble (and certainly is huge performance sink). > > Yes, I though that fopen and fclose should be called once before this > loop and once after the loop respectively. > For these two C programs in fifoC.zip, I tried to > avoid fopen-fclose in the inner loop, by replacing fclose with > fflush. But all my attempts with moving fopen-fclose and/or setting > fflush (for something still needs to push off the buffer) lead either > to fail of fgets or to hanging in waiting IO. > And I remain in wonder how to avoid these repeated fopen and fclose. > > I could try read-write (in C), but expect to meet the same problem > with open-close. > > If I am stuck with the named pipes, the next attempt will be either a > (1) socket or a > (2) fork + shared memory (or what it is called) for the two processes. > > But, probably this needs an iterface to C for Axiom. > > C interface > ----------- > Haskell has such. I tried it for Haskell <-> C program for a function > String -> String -- only this type is needed. > A Haskell function calls the C function convString which outputs a > string to the named pape and inputs the response string from the back > pipe. The loop works, but again, slowly, due to the repeated > fopen-fclose in the C function. The pure Haskell function for this > (without interface) runs 90 times faster. > > Has Axiom (FriCAS) a C interface? > If it has, then the Haskell -- Axiom interface by (1) or (2) > will be reduced to the Haskell -- C program interface by a (1) or (2) > -- ? > Currently FriCAS C interface works via Lisp. In Lisp one writes things like: (fricas-foreign-call |sockSendInt| "sock_send_int" int (purpose int) (val int)) giving C return type and then argument names and types. >From Spad one can then do: sock_send_int(purpose : Integer, val : Integer) : Integer == sockSendInt(purpose, val)$Lisp For file IO there is a problem: read/wrote take as argument adress of a buffer, but some Lisps (notable clisp) do not provide any official way to pass address of Lisp object to foreign routine, so one has to add extra code to copy data between Lisp and C buffers (if you want to use strings copy may be needed anyway, because Lisp and C probably use different representation for strings (wide characters in Lisp, multibyte in C). -- Waldek Hebisch [email protected] -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
