views:

753

answers:

4

I'm trying to follow this tutorial: http://cl-cookbook.sourceforge.net/sockets.html

And I cannot get it working because of the port package. First the "(in-package :port)" did not work, it said the package could not be found. So I changed it to "(clc:clc-require :port)" but this causes another error:

"INTERN("STRUCTURE-KCONSTRUCTOR"): # is locked ..."

What should I do under ubuntu to make it work?

+1  A: 

Take a look at asdf-install. After setting it up, lisp packages are installed as easy as:

(require 'asdf-install)
(asdf-install:install 'package-name)

Anyways, clisp is not that used anymore. Take a look at SBCL which is most wideely used common lisp implementation.

Also, for learning common lisp you'd better start with Practical Common Lisp as an excellent and free book.

Dev er dev
+1  A: 

Install the cl-port package with apt-get install cl-port.

kmkaplan
+1  A: 

require and in-package are two different things.

  • require loads certain code into the running lisp image, in order to make it available (if it isn't already there).
  • in-package changes the "current" namespace to a certain package, so that you can call the objects from this package without the package prefix (e.g. split instead of cl-ppcre:split). This package has to "exist" in the runtime already for that, of course.
Svante
+2  A: 

It is unfortunate that the cl-cookbook still refers to PORT from CLOCC. I recommend against PORT in particular and CLOCC in general.

The good news is newer, better socket libraries exist, and you will not have much trouble using those instead. Here are your options:

  • usocket is a portability library that abstracts over the socket features in various Lisp implementations. It is the spiritual successor to trivial-sockets, and many Common Lisp libraries are depending on usocket today.

    I recommend usocket for new users.

  • The other contender is iolib, which re-implements sockets using FFI instead of building on the implementation's facilities. It also sports other ambitious innovations, like a replacement for Common Lisp pathnames, I/O multiplexing, and its own stream abstraction.

    Programmers willing to read source code and unit tests will find iolib enjoyable, but it is still in a state of flux and lacks documentation.

    I recommend iolib for avid hackers.

Many installation methods are possible. As an Ubuntu user, you can just use aptitude:

$ aptitude install cl-usocket
$ clisp
[1]> (asdf:operate 'asdf:load-op :usocket)

Beware that the Common Lisp packages in Debian and Ubuntu are often outdated and rather different from upstream. If you are looking for help online, you will get more helpful responses if you switch to upstream version of those packages.

Personally I use Debian, but run clbuild instead of the Debian packages for Lisp. Note that clbuild needs upstream CLISP, not the CLISP that Ubuntu ships.

David Lichteblau