User Tools

Site Tools


using_ecl_embeddable_common-lisp_on_sdf

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
using_ecl_embeddable_common-lisp_on_sdf [2021/03/11 05:20] – created hc9using_ecl_embeddable_common-lisp_on_sdf [2021/03/11 05:37] – [ASDF / enabling readline] hc9
Line 15: Line 15:
 By default ECL starts up in interactive mode. Log into SDF host //miku// and type "'ecl'"; you should see something like below: 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 +<code> 
-  Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya + 
-  Copyright (C) 1993 Giuseppe Attardi +ECL (Embeddable Common-Lisp) 11.1.1 
-  Copyright (C) 2000 Juan J. Garcia-Ripoll +Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya 
-  ECL is free software, and you are welcome to redistribute it +Copyright (C) 1993 Giuseppe Attardi 
-  under certain conditions; see file 'Copyright' for details. +Copyright (C) 2000 Juan J. Garcia-Ripoll 
-  Type :h for Help. +ECL is free software, and you are welcome to redistribute it 
-  Top level. +under certain conditions; see file 'Copyright' for details. 
-  >+Type :h for Help. 
 +Top level. 
 +
 + 
 +</code>
  
 The default ECL prompt is ">". Enter Common-Lisp commands in the usual way: The default ECL prompt is ">". Enter Common-Lisp commands in the usual way:
  
-  > (+ 1 2 3) +<code> 
-  6+ 
 +> (+ 1 2 3) 
 +6 
 + 
 +> (* 4 5) 
 +20
  
-  > (* 4 5+> (format t "hello SDF~&amp;"
-  20+hello SDF 
 +NIL 
 +>
  
-  > (format t "hello SDF~&amp;"+</code>
-  hello SDF +
-  NIL +
-  >+
  
 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" . 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" .
Line 46: Line 54:
 ex: hello.lsp ex: hello.lsp
  
-  % echo '(format t "~&amp;Hello SDF~&amp;")' hello.lsp+<code>
  
-  % ecl -norc -script hello.lsp +% echo '(format t "~&amp;Hello SDF~&amp;")' > hello.lsp 
-  Hello SDF+ 
 +% ecl -norc -script hello.lsp 
 +Hello SDF 
 + 
 +</code>
  
 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): 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 "(princ (* 1 2 3))" +<code> 
-  6+ 
 +% ecl -norc -shell /dev/null -eval "(princ (* 1 2 3))" 
 +6 
 + 
 +</code>
  
 A nicer way to accomplish the same is to create a small shell script: A nicer way to accomplish the same is to create a small shell script:
  
-  #!/bin/sh +<code> 
-  # lispit - executes a lisp expression and dumps it to stdout+ 
 +#!/bin/sh 
 +# lispit - executes a lisp expression and dumps it to stdout 
 + 
 +LSP_EXPR=${@}
  
-  LSP_EXPR=${@}+if [ "$#" -eq 0 ]; then 
 +        echo "lispit - executes a lisp expression" 
 +        echo "  usage: lispit '(lisp_expression)'" 
 +        echo "" 
 +        exit 1 
 +fi
  
-  if [ "$#" -eq 0 ]; then +ecl -norc -shell /dev/null -eval "(princ ${LSP_EXPR} )" 
-          echo "lispit executes a lisp expression" +echo "" 
-          echo "  usage: lispit '(lisp_expression)'+exit 0
-          echo "" +
-          exit +
-  fi+
  
-  ecl -norc -shell /dev/null -eval "(princ ${LSP_EXPR} )" +</code>
-  echo "" +
-  exit 0+
  
 Example run: Example run:
  
-  % lispit '(mapcar (lambda (x) (expt x 2)) `(1 2 3 4 5))' +<code> 
-  (1 4 9 16 25)+ 
 +% lispit '(mapcar (lambda (x) (expt x 2)) `(1 2 3 4 5))' 
 +(1 4 9 16 25) 
 + 
 +</code>
  
 ===== ASDF / enabling readline ===== ===== ASDF / enabling readline =====
Line 87: Line 111:
 1) Create the user-level ASDF repository: 1) Create the user-level ASDF repository:
  
-  % mkdir -p $HOME/LISP/ASDF+<code> 
 + 
 +% mkdir -p $HOME/LISP/ASDF 
 + 
 +</code>
  
 2) Create the ASDF config directory and config file*: 2) Create the ASDF config directory and config file*:
  
-  % cd $HOME +<code> 
-  % mkdir -p .config/common-lisp/source-registry.conf.d + 
-  % vi .config/common-lisp/source-registry.conf.d/asdf.conf+% cd $HOME 
 +% mkdir -p .config/common-lisp/source-registry.conf.d 
 +% vi .config/common-lisp/source-registry.conf.d/asdf.conf 
 + 
 +# ../asdf.conf 
 +;;additional directory for ASDF to search (no recursion): 
 +(:directory "/LISP/ASDF/")
  
-  # ../asdf.conf +</code>
-  ;;additional directory for ASDF to search (no recursion): +
-  (:directory "/LISP/ASDF/")+
  
 *note: you can call the conf file anything you want. *note: you can call the conf file anything you want.
Line 103: Line 135:
 3) Download ecl-readline module and copy select files to $HOME/LISP/ASDF: 3) Download ecl-readline module and copy select files to $HOME/LISP/ASDF:
  
-  % cd /tmp +<code> 
-  % snarf http://www.common-lisp.net/project/ecl-readline/releases/ecl-readline-0.4.1.tar.gz + 
-  % tar xzf ecl-readline-0.4.1.tar.gz +% cd /tmp 
-  % cd ecl-readline-0.4.1/ +% snarf http://www.common-lisp.net/project/ecl-readline/releases/ecl-readline-0.4.1.tar.gz 
-  % cp ecl-*.* $HOME/LISP/ASDF/+% tar xzf ecl-readline-0.4.1.tar.gz 
 +% cd ecl-readline-0.4.1/ 
 +% cp ecl-*.* $HOME/LISP/ASDF/ 
 + 
 +</code>
  
 4) Create the ECL startup file: 4) Create the ECL startup file:
  
-  # $HOME/.eclrc +<code> 
-  (require 'asdf) + 
-  (asdf:operate 'asdf:load-op 'ecl-readline) +# $HOME/.eclrc 
-  (ecl-readline::enable)+(require 'asdf) 
 +(asdf:operate 'asdf:load-op 'ecl-readline) 
 +(ecl-readline::enable) 
 + 
 +</code>
  
 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. 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.
Line 121: Line 161:
  
 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: 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:
 +
 +<code>
  
   # $HOME/.eclrc   # $HOME/.eclrc
Line 137: Line 179:
   User sub-shell is spawned. SHELL_CMD be string or symbol, 256 characters max."   User sub-shell is spawned. SHELL_CMD be string or symbol, 256 characters max."
      (ext:system shell_cmd))      (ext:system shell_cmd))
 +
 +</code>
  
 ===== References: ===== ===== References: =====
using_ecl_embeddable_common-lisp_on_sdf.txt · Last modified: 2021/03/12 18:34 by hc9