SLURP

I have written Common Lisp, Erlang and Javascript versions of a library I call SLURP. It’s based on the ideas used in the Smalltalk SRP library.

Right now it’s pretty rough, but useable enough to transfer simple objects with named slots (eg CLOS objects, Javascript objects). On Erlang I’m using some very ugly code to get it to work with Erlang records (which are a compile-time phenomena).

It currently supports some basic types such as bytes, unsigned integers, strings, lisp-style cons cells and arrays of the basic types.

In the future I might look at performance optimization and writing a formal definition (machine checkable) for the protocol.

The Good

Encoding native lisp objects is as simple as calling slurp:encode

(defmethod send-state-change (object-id state-change)
  (let* ((encodedState (slurp:encode state-change))

The Bad

In Javascript, we have to add additional properties to a prototype to tell SLURP how to encode it:

function FuraxSubscriptionRequest(objectId, clientId) {
        this['OBJECT-ID'] = objectId;
        this['CLIENT-ID'] = clientId;
}

FuraxSubscriptionRequest.prototype['SLURP_TYPE'] = "furax-subscription-request";
FuraxSubscriptionRequest.prototype['SLURP_PACKAGE'] = "FURAX";

The Ugly

In Erlang we have to grab the record descriptions at compile time and save them in a dictionary for later reflection

The source is available by getting:

hg clone http://subvert-the-dominant-paradigm.net/repos/hgwebdir.cgi/slurp