[plt-scheme] ann: erlang-scheme interop

From: Eric Sessoms (nubgames at gmail.com)
Date: Tue Jul 8 08:34:14 EDT 2008

I've put together a small scheme package to talk to erlang (attached).
 It's still very much a toy and under development, but I wanted to
release it early for anyone crazy enough to want to play with it.

What it is:  Basically, it's a port of Distel from emacs lisp over to
scheme.  It talks to erlang using its own protocol and impersonates an
erlang node on the network.  It aims to provide an abstraction such
that erlang processes look like scheme threads, and vice-versa.
Communication from scheme to erlang is done with (a wrapper around)
thread-send.  Messages from erlang to scheme get routed to thread
mailboxes so that they can be picked up with thread-receive.

What works: bi-directional communication between scheme and erlang,
using native data-types and communication mechanisms in both
languages.

What doesn't (I did say it it's just a toy):  Linking is not yet
implemented.  In erlang, "linking" establishes a connection between
two processes such that if one dies the other is notified.  This is
TBD.  Right now, scheme does not register with the erlang port-mapper,
which means that scheme has to initiate contact with erlang.  Once
scheme initiates contact, messages can flow both ways.  Lastly, much
of the more interesting erlang functionality is implemented using
higher-level protocols built on top of the primitive message passing
(i.e., gen_server).  Most of this isn't yet done.

Below are scheme and erlang transcripts from a play session.

Welcome to MzScheme v4.0.2 [3m], Copyright (c) 2004-2008 PLT Scheme Inc.
> (enter! "erlang.ss")
 [loading erlang.ss]
 [loading etc]
> (erlang-set-node-name! 'scheme at Azathoth)
> (erlang-console)
> (erlang-self)
#(TYPE erlang-pid scheme at Azathoth 1 0 1)
> (define t (erlang-node 'test))
> (erlang-echo-test t "r u there?")
#(#(TYPE erlang-new-ref scheme at Azathoth 1 #"\0\0\0\1\0\0\0\0\0\0\0\0")
  "r u there?")
> (erlang-rpc-call t 'echo 'echo "hello, erlang!")
#(#(TYPE erlang-new-ref scheme at Azathoth 1 #"\0\0\0\2\0\0\0\0\0\0\0\0")
  "hello, erlang!")
> (thread-receive)
"hello, scheme!"
> (erlang-rpc-call t 'erlang 'display "w00t!")
#(#(TYPE erlang-new-ref scheme at Azathoth 1 #"\0\0\0\3\0\0\0\0\0\0\0\0") true)
> (erlang-rpc-call t 'code 'get_path)
#(#(TYPE erlang-new-ref scheme at Azathoth 1 #"\0\0\0\4\0\0\0\0\0\0\0\0")
  ("."
   "/usr/local/lib/erlang/lib/kernel-2.12.3/ebin"
   "etc"))

Eshell V5.6.3  (abort with ^G)
(test at Azathoth)1> node().
test at Azathoth
(test at Azathoth)2> c(echo).
{ok,echo}
(test at Azathoth)3> {console, 'scheme at Azathoth'} ! "hello, scheme!".
"hello, scheme!"
(test at Azathoth)4> "w00t!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v01.tbz
Type: application/octet-stream
Size: 6616 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20080708/6cea5090/attachment.obj>

Posted on the users mailing list.