====== Using ECL (Embeddable Common-Lisp) on SDF ======
==== Contents: ====
* [[#what|What is ECL?]]
* [[#compare|ECL vs CLISP]]
* [[#basics|ECL Basics]]
* [[#oneliners|ECL one-liners]]
* [[#asdf|ASDF]]
* [[#customize|Customizations]]
* [[#refs|References]]
===== What is ECL? =====
ECL stands for //Embeddable Common-Lisp// and is a free open source ANSI Common-Lisp implementation. Its distinguishing attributes are maintaining a small-footprint, and being embeddable with existing C/C++ applications. ECL is LGPL licensed and hosted at [[http://ecls.sourceforge.net/|ecls.sourceforge.net]].
ECL-11.1.1 is currently available to MetaARPA members on most SDF hosts.
===== ECL vs CLISP =====
There are currently two Common-Lisp implementations available on SDF; ECL and CLISP. Both are largely compliant with the ANSI Common-Lisp standard. Each supports various object systems, debugging, bytecode compiling, unicode, sockets, streams, etc. CLISP comes with built-in readline support; ECL doesn't, though it can be added; see the [[#asdf|ASDF]] section. In addition to being smaller and faster than CLISP, ECL can be embedded in C/C++ programs, allow embedded C/C++ code in Lisp programs, and produce stand-alone ELF executables. ECL is also very well documented.
===== ECL Basics =====
By default ECL starts up in interactive mode. Log into SDF host //miku// and type "'ecl'"; you should see something like below:
ECL (Embeddable Common-Lisp) 11.1.1
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
In-line help is available ; type :h for options. The debugger can be entered using "(break)" ; once entered typed :h to see options. To exit the ECL interactive session type ":exit" .
===== ECL one-liners =====
To use ECL as a script executor (ie. CGI) the //-shell// and/or //-eval// options can be used. The //-norc// is often a good addition so as to avoid unnecessary loading of modules, etc.
ASDF (//Another System Definition Facility//) is an extensible build facility for Common-Lisp software. ECL comes with ASDF bundled in, however on SDF, users must setup their own ASDF repository under their $HOME directory.
The following outlines the process, using the //ecl-readline// module (adds GNU readline support to ECL) as example:
1) Create the user-level ASDF repository:
% mkdir -p $HOME/LISP/ASDF
2) Create the ASDF config directory and config file*:
The next time you startup ECL it will compile the ecl-readline module and launch an interactive session. With ecl-readline enabled the default ECL prompt is "//CL-USER[n]>//" and you should then be able to use Emacs-style command editing and history recall. If you don't like the provided prompt you can change it by editing the //ecl-readline.lisp// file.
Additional modifications can be made to the ECL startup file, such as user-defined functions and tweaks to various modules. Below is a more nuanced example which reduces the verbosity at startup, modifies ecl-readline's history file location, and adds an external SHELL function similar to that found in CLISP:
# $HOME/.eclrc
(require 'asdf)
(setf ASDF:*ASDF-VERBOSE* nil) ; quiets ASDF output some
(setf *load-verbose* nil) ; quiets the LOAD process some