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

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
using_ecl_embeddable_common-lisp_on_sdf [2021/03/11 05:30] – [ECL Basics] hc9using_ecl_embeddable_common-lisp_on_sdf [2021/03/11 05:42] – [References:] hc9
Line 56: Line 56:
 <code> <code>
  
-  % echo '(format t "~&amp;Hello SDF~&amp;")' > hello.lsp+% echo '(format t "~&amp;Hello SDF~&amp;")' > hello.lsp
  
-  % ecl -norc -script hello.lsp +% ecl -norc -script hello.lsp 
-  Hello SDF+Hello SDF
  
 </code> </code>
Line 65: Line 65:
 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:
Line 72: Line 76:
 <code> <code>
  
-  #!/bin/sh +#!/bin/sh 
-  # lispit - executes a lisp expression and dumps it to stdout+# lispit - executes a lisp expression and dumps it to stdout
  
-  LSP_EXPR=${@}+LSP_EXPR=${@}
  
-  if [ "$#" -eq 0 ]; then +if [ "$#" -eq 0 ]; then 
-          echo "lispit - executes a lisp expression" +        echo "lispit - executes a lisp expression" 
-          echo "  usage: lispit '(lisp_expression)'" +        echo "  usage: lispit '(lisp_expression)'" 
-          echo "" +        echo "" 
-          exit 1 +        exit 1 
-  fi+fi
  
-  ecl -norc -shell /dev/null -eval "(princ ${LSP_EXPR} )" +ecl -norc -shell /dev/null -eval "(princ ${LSP_EXPR} )" 
-  echo "" +echo "" 
-  exit 0+exit 0
  
 </code> </code>
Line 92: Line 96:
 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 103: 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*:
Line 109: Line 121:
 <code> <code>
  
-  % cd $HOME +% cd $HOME 
-  % mkdir -p .config/common-lisp/source-registry.conf.d +% mkdir -p .config/common-lisp/source-registry.conf.d 
-  % vi .config/common-lisp/source-registry.conf.d/asdf.conf+% vi .config/common-lisp/source-registry.conf.d/asdf.conf
  
-  # ../asdf.conf +# ../asdf.conf 
-  ;;additional directory for ASDF to search (no recursion): +;;additional directory for ASDF to search (no recursion): 
-  (:directory "/LISP/ASDF/")+(:directory "/LISP/ASDF/")
  
 </code> </code>
Line 123: 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 144: Line 164:
 <code> <code>
  
-  # $HOME/.eclrc +# $HOME/.eclrc 
-  (require 'asdf) +(require 'asdf) 
-  (setf ASDF:*ASDF-VERBOSE* nil) ; quiets ASDF output some +(setf ASDF:*ASDF-VERBOSE* nil) ; quiets ASDF output some 
-  (setf *load-verbose* nil)       ; quiets the LOAD process some +(setf *load-verbose* nil)       ; quiets the LOAD process some 
-  (asdf:operate 'asdf:load-op 'ecl-readline) +(asdf:operate 'asdf:load-op 'ecl-readline) 
-  (ecl-readline::enable :history-file "/var/tmp/.ecl-history"+(ecl-readline::enable :history-file "/var/tmp/.ecl-history"
-  ;; +;; 
-  ;; customizations+;; customizations
  
-  ;; GNU clisp-like SHELL cmd +;; GNU clisp-like SHELL cmd 
-  (defun shell (&amp;optional (shell_cmd "$SHELL")) +(defun shell (&amp;optional (shell_cmd "$SHELL")) 
-  "Args: (&amp;optional shell_cmd) +"Args: (&amp;optional shell_cmd) 
-  SHELL calls the EXT:SYSTEM function. Executes SHELL_CMD if given, otherwise +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." +User sub-shell is spawned. SHELL_CMD be string or symbol, 256 characters max." 
-     (ext:system shell_cmd))+   (ext:system shell_cmd))
  
 </code> </code>
Line 172: Line 192:
 ---- ----
  
-$Id: ecl_tutorial.html,v 1.4 2011/12/12 18:10:28 jgw Exp $ [[http://sdf.org/?tutorials/ecl_tutorial|Using ECL (Embeddable Common-Lisp) on SDF]] - legacy link+$Id: ecl_tutorial.html,v 1.4 2011/12/12 18:10:28 Exp jgw $ [[http://sdf.org/?tutorials/ecl_tutorial|Using ECL (Embeddable Common-Lisp) on SDF]] - legacy link
  
using_ecl_embeddable_common-lisp_on_sdf.txt · Last modified: 2021/03/12 18:34 by hc9