[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Noob question: (re)compile FFI-accessing code within
From: |
Graham Fawcett |
Subject: |
Re: [Chicken-users] Noob question: (re)compile FFI-accessing code within REPL |
Date: |
Thu, 28 Jun 2007 14:25:21 -0400 |
On 6/28/07, Martin Percossi <address@hidden> wrote:
Now, supposing I wanted to change the c-test to:
(define (c-test)
($ printf "BOO!")
The question is: am I obliged to recompile outside of the REPL loop?
In other words, is there a `compile' command which lets me recompile
test.scm from within the REPL?
Not within the interpeter, no. Instead you could try one of these:
* (define (my-printf . args) ($ printf args)) in your compiled code
and then (define (c-test) (my-printf "BOO")) in a non-compiled
Scheme file (or just type it in the interpreter). In other words,
compile the "primitives" only.
* Don't use the REPL. Define your code to be compiled, then write a
test script (think "unit tests") that exercises your code. Use a
Makefile or other script to build compile your code as needed and
automatically run the tests. When it's sufficiently cooked, load it
in your REPL and play around.
* Use the lazy-ffi instead. It works nicely at the REPL:
(use lazy-ffi)
#~"libc.so.6"
(define (c-test) (#~printf "BOO!"))
* The "inline" egg has support for compiling C on the fly, into a
temporary shared-library that is then loaded into the interpreter. A
similar approach could work for Scheme procedures, I think, though
I've never tried. The approach would be to
* write out the procedure definition to a temporary file,
* csc -s /tmp/the-file.scm -o /tmp/tempXXX.so
* load the /tmp/tempXXX shared library.
It might not be a one-size-fits-all solution, but it might just
work. Of course, it doesn't exist yet. :-)
- Is quack generally preferred over hen in emacs? Quack looks pretty
good; haven't tried hen yet. Keep in mind that I will be using windows
eventually.
I haven't used hen either; I do run Quack and haven't had any problems
with it. I find that paredit-mode is indispensible, and mmm-mode can
help with literal sections (#<<EOF) and some other syntactic stuff.
- When I download the readline egg, I get nice command completion on the
csi REPL -- sweet! Unfortunately, it doesn't seem to work within emacs
(quack), either in the REPL or when editing a scheme file. Is there any
way to make this work?
Hm. You could try running csi in a term buffer (M-x term). You would
have to tell Quack (or cmuscheme?) where to find your csi buffer,
though, if you want them to integrate properly. This might work:
(defun run-csi-in-term ()
(interactive)
(term "/usr/local/bin/csi")
(rename-buffer "*scheme*")))
There might be easier solutions though, other than readline
support. Using a tags-table would be the "Emacs way" I think.
Good luck,
Graham