[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Guile object channel
From: |
Keisuke Nishida |
Subject: |
Guile object channel |
Date: |
Tue, 24 Apr 2001 22:37:18 -0400 |
User-agent: |
Wanderlust/2.4.0 (Rio) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.0.102 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI) |
This is an idea of my new Guile Emacs implementation.
This time, I'm going to make it based on a simple
distributed object model, like CORBA.
The idea and its implementation is really simple.
Now, I'm going to start Guile from Emacs as an
external process. I have a module (guile channel),
which provides a channel to Guile objects:
% guile
guile> (use-modules (guile channel))
guile> (open-object-channel)
channel> eval (current-module)
token = (%object-token%0 . "#<directory (guile-user) 8083390>")
channel> eval (module-ref %object-token%0 'assq)
token = (%object-token%1 . "#<primitive-procedure assq>")
Guile's objects are identified by unique tokens,
and we can control them from Emacs.
Now, I have an Emacs-side interface `guile.el':
(require 'guile)
(defvar adapter (guile:make-adapter "guile"))
(guile:eval '(current-module) adapter) => %object-token%0
(guile:eval '(module-ref %object-token%0 'assq) adapter)
=> %object-token%1
Some objects, like symbols and strings, are copied instead
of identified by tokens. Thus, we get the following:
(guile:eval '(+ 1 2) adapter) => 3
(guile:eval '(cons 1 2) adapter) => (1 . 2)
(guile:eval '(%object-token%1 'x '((x . 1) (y . 2))) adapter)
=> (x . 1)
Now, we can import Guile's procedures into Emacs:
(defun string-append (s1 s2)
(guile:eval `(string-append ,s1 ,s2) adapter))
(string-append "foo" "bar") => "foobar"
One major problem with this approach is GC. I have to
destroy unnecessary tokens somehow. I could use a weak
pointer or finalizer, but GNU Emacs doesn't provides
either of them. I'll need to make a patch some time.
Other problems, such as I/O, exceptions, signals, can
be solved without any patch, I guess.
A primitive implementation of this approach can be found at
guile-vm/module/guile/channel.scm and guile-vm/emacs/guile.el
in CVS.
I'm going to write a Guile Scheme mode and an interactive
source level debugger for my VM using this approach.
Thanks,
Keisuke
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Guile object channel,
Keisuke Nishida <=