using_ecl_embeddable_common-lisp_on_sdf
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
using_ecl_embeddable_common-lisp_on_sdf [2021/03/11 05:23] – [ASDF / enabling readline] hc9 | using_ecl_embeddable_common-lisp_on_sdf [2021/03/12 18:34] (current) – [References:] hc9 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Using ECL (Embeddable Common-Lisp) on SDF ====== | ||
+ | |||
+ | ===== What is ECL? ===== | ||
+ | |||
+ | ECL stands for // | ||
+ | |||
+ | 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' | ||
+ | |||
+ | ===== ECL Basics ===== | ||
+ | |||
+ | By default ECL starts up in interactive mode. Log into SDF host //miku// and type "' | ||
+ | |||
+ | < | ||
+ | |||
+ | 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 ' | ||
+ | Type :h for Help. | ||
+ | Top level. | ||
+ | > | ||
+ | |||
+ | </ | ||
+ | |||
+ | The default ECL prompt is ">" | ||
+ | |||
+ | < | ||
+ | |||
+ | > (+ 1 2 3) | ||
+ | 6 | ||
+ | |||
+ | > (* 4 5) | ||
+ | 20 | ||
+ | |||
+ | > (format t "hello SDF~& | ||
+ | hello SDF | ||
+ | NIL | ||
+ | > | ||
+ | |||
+ | </ | ||
+ | |||
+ | In-line help is available ; type :h for options. The debugger can be entered using " | ||
+ | |||
+ | ===== 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. | ||
+ | |||
+ | ex: hello.lsp | ||
+ | |||
+ | < | ||
+ | |||
+ | % echo ' | ||
+ | |||
+ | % ecl -norc -script hello.lsp | ||
+ | Hello SDF | ||
+ | |||
+ | </ | ||
+ | |||
+ | It's also possible to use ECL to execute simple Common-Lisp one-liners at the command line (note that //princ// is needed for screen output): | ||
+ | |||
+ | < | ||
+ | |||
+ | % ecl -norc -shell /dev/null -eval " | ||
+ | 6 | ||
+ | |||
+ | </ | ||
+ | |||
+ | A nicer way to accomplish the same is to create a small shell script: | ||
+ | |||
+ | < | ||
+ | |||
+ | #!/bin/sh | ||
+ | # lispit - executes a lisp expression and dumps it to stdout | ||
+ | |||
+ | LSP_EXPR=${@} | ||
+ | |||
+ | if [ " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo "" | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | ecl -norc -shell /dev/null -eval " | ||
+ | echo "" | ||
+ | exit 0 | ||
+ | |||
+ | </ | ||
+ | |||
+ | Example run: | ||
+ | |||
+ | < | ||
+ | |||
+ | % lispit ' | ||
+ | (1 4 9 16 25) | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== ASDF / enabling readline ===== | ||
+ | |||
+ | 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 // | ||
+ | |||
+ | 1) Create the user-level ASDF repository: | ||
+ | |||
+ | < | ||
+ | |||
+ | % mkdir -p $HOME/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | 2) Create the ASDF config directory and config file*: | ||
+ | |||
+ | < | ||
+ | |||
+ | % cd $HOME | ||
+ | % mkdir -p .config/ | ||
+ | % vi .config/ | ||
+ | |||
+ | # ../ | ||
+ | ;; | ||
+ | (:directory "/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | *note: you can call the conf file anything you want. | ||
+ | |||
+ | 3) Download ecl-readline module and copy select files to $HOME/ | ||
+ | |||
+ | < | ||
+ | |||
+ | % cd /tmp | ||
+ | % snarf http:// | ||
+ | % tar xzf ecl-readline-0.4.1.tar.gz | ||
+ | % cd ecl-readline-0.4.1/ | ||
+ | % cp ecl-*.* $HOME/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | 4) Create the ECL startup file: | ||
+ | |||
+ | < | ||
+ | |||
+ | # $HOME/ | ||
+ | (require 'asdf) | ||
+ | (asdf: | ||
+ | (ecl-readline:: | ||
+ | |||
+ | </ | ||
+ | |||
+ | 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 "// | ||
+ | |||
+ | ===== Customizations ===== | ||
+ | |||
+ | 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' | ||
+ | |||
+ | < | ||
+ | |||
+ | # $HOME/ | ||
+ | (require 'asdf) | ||
+ | (setf ASDF: | ||
+ | (setf *load-verbose* nil) ; quiets the LOAD process some | ||
+ | (asdf: | ||
+ | (ecl-readline:: | ||
+ | ;; | ||
+ | ;; customizations | ||
+ | |||
+ | ;; GNU clisp-like SHELL cmd | ||
+ | (defun shell (& | ||
+ | "Args: (& | ||
+ | SHELL calls the EXT:SYSTEM function. Executes SHELL_CMD if given, otherwise | ||
+ | User sub-shell is spawned. SHELL_CMD be string or symbol, 256 characters max." | ||
+ | | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== References: ===== | ||
+ | |||
+ | * //ecl(1)// and // | ||
+ | * http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | $Id: ecl_tutorial.html, | ||