Rutils ?

I was excited to try this out when I came across it … but it looks like (today!) the github repo is not in a compilable state, at least on Allegro CL.

CL-USER(44): (ql:quickload 'rutils)
To load "rutils":
  Load 1 ASDF system:
    rutils
; Loading "rutils"
[package editor-hints.named-readtables]...........
[package rutils.readtable]........................
[package rutils.core].............................
[package rutils.misc].............................
[package rutils.anaphora].........................
[package rutils.list].............................
[package rutils.string]...........................
[package rutils.hash-table].......................
[package rutils.sequence].........................
[package rutils.pair].............................
[package rutils.tree].............................
[package rutils.array]............................
[package rutils.abbr].............................
[package rutils]..................................
[package rutil].; While EVALUATING an unknown function in
                #P"/usr/local/google/home/agam/quicklisp/dists/quicklisp/software/rutils-20140425-git/core/readtable.lisp":
Error: There is no readtable named :RUTILS.READTABLE.RUTILS-READTABLE.
  [condition type: SIMPLE-ERROR]

Update:

It works fine on SBCL(!)

I think this is because Allegro CL (which, in its defense, is trying to be clever) supports a named readtable feature that is getting triggered by the text at the top of this file. Oh well, I guess I’ll have to stick with SBCL.

Anyway, coming back to rutils: read the announcement. I for one totally agree with this goal of collecting and consolidating utility code, and as a newbie, will do my best to learn as much as I can from it!

So much for the AllegroCL trial

I suppose it’s worth learning anyway, it seems to give a very precise control over compilation, has a bunch of libraries and is very well documented. Also, an email to support@franz.com, which turned out to be a very silly question, was answered promptly. One day, I’m sure I will buy the Professional version!

However, I can’t always use this as an experimental Common Lisp platform. Today I wanted to try out Genworks, but when I tried to load it, I saw

Error:
An explicit gc call caused tenuring and a need for 786432 more bytes of heap.
This request cannot be satisfied because you have hit the Allegro CL Free Express heap limit.
The Student Edition has an unlimited heap.
For more information on the Student Edition, see http://www.franz.com/downloads/student.lhtml.
For an evaluation of our Enterprise or Professional Editions please contact us at sales@franz.com or (510) 452-2000.
    [condition type: STORAGE-CONDITION]

I don’t want to pretend to be a student, so … back to SBCL!

AllegroGraph: Getting Started

I’m following along with Mark Watson’s excellent book on using AllegroGraph, but the automated install mentioned at the beginning didn’t work for me.

While I figure this out, the following manual version does work:

Install the server

  • Download and extract the tar.gz file

  • ./agraph-4.13.1/install-agraph ~/Lisp/AllegroGraph

  • ./AllegroGraph/bin/agraph-control --config AllegroGraph/lib/agraph.cfg start

Add a test user

(say user:test, password:xyzzy)

Install the client

  • Download and extract the tar.gz file

  • :ld $home/Lisp/agraph-4.13.1-linux86-acl90-client-lisp-acl9.0/agraph4.fasl

  • (in-package :db.agraph.user)

  • (create-triple-store "tmp-rdfstore-1"
    :user "test"
    :password "xyzzy")

Note: the example from the book uses /ns/name, but this is not allowed

  • (enable-!-reader)

Note: the book omits this at the beginning, but this is essential to do what comes next (without this, something like !owl is treated like a package name)

  • (add-triple !owl:cat !owl:eats !owl:fish)

(get-triple-by-id 1)
<cat eats fish>

Enjoy! More to follow, in fits and starts …

Using AllegroCL with Emacs

One way is the SLIME way — similar to any other lisp/scheme implementation, install it, set inferior-lisp-program, add (slime-setup '(slime-fancy)) to your .emacs, and run M-x slime. Boom! Done.

There is another way, using an Emacs Lisp connection suggested by Franz (the guys who sell AllegroCL).

You’ll need to add this to your Emacs file (depending on when and what you download, your path may be slightly different):

(load-file "/Applications/AllegroCLexpress.app/Contents/Resources/eli/fi-site-init.el")

This done (and loaded), run fi:common-lisp. The first time you do this, it’ll ask you which buffer name to use (use the suggested default), the host (leave it set to the default, localhost — though this should illustrate how easy a remote session would be!), a process directory (pick some local directory, say ~/lisp/ ?) and paths to the image name and image file, which will correspond to alisp and alisp.dxl respectively, in the app’s directory.

At this point, you should see something like this:

Allegro CL  Emacs
Allegro CL Emacs

Now at this point, it’s a matter of getting comfortable in the environment. Obvious similarities to Slime include the appearance of the function’s argument list once you press space after the name of the function. It might help to think of this as a sort of combination of Slime and Paredit. So for example, C-c ] acts as a “super parenthesis”, adding as many closing parentheses as needed.

Here are a few other “helpers”:

  • M-D => Describe symbol
  • C-c i => Insert the argument list of the function
  • C-c f => Lookup the function reference in a browser (defaults to Safari on OSX)
  • C-c Tab => Autocomplete name under cursor
  • C-c ? => Apropos
  • C-c c => List callers

… and so on. Ultimately, the whole point is just to make writing, running and debugging code easier!

(Disclaimer: this isn’t necessary at all; AllegroCL comes with an IDE (though you’ll need to install X11 to use it). Since I’m used to using Emacs in general and haven’t used an IDE for a while now, this is something I prefer, but everything here is entirely a matter of personal preference!)