Monday 2 January 2017

Lisp Programing Environment Setup in Ubuntu

Package Installation

Packages for Lisp
Lisp Package Required

If you are new to Lisp programing , here's the packages that you need to install.

  • emacs
  • slime
  • sbcl
Installation commands for the same are




  • sudo apt-get install emacs
  • sudo apt-get install slime
  • sudo apt-get install sbcl

And you are good to go.

Your First Lisp Program


To begin programing type emacs in the terminal, to launch emacs.
I strongly recommend using emacs and not gedit.  Compare the two if you want, I am 100% sure you will prefer emacs.

  1. Create a new file using the file menu. 
  2. Type some lisp code.
  3. Save again using the file menu.

Shortcuts in Emacs

Do not attempt to use the shortcut keys, emacs have different shortcut keys. Which means that Ctrl+x will not be a shortcut for cut, instead it is a shortcut for save.
Either learn emacs shortcuts and or instead use the GUI.

Compiling & Execution


Create the following script file. Save it as sbcl.compile.
 
#!/bin/bash
    sbcl --noinform --eval "(compile-file \"$1\")" --eval "(quit)" > /dev/null


Next create the following script file. Save this as sbcl.run.

#!/bin/bash
    sbcl --noinform --load "$1" --quit --end-toplevel-options "$@"

Finally to add the execute permission to these files.

chmod +x sbcl.*



Fire up the following commands in succession to get your code running

  • sh sbcl.compile filename.lisp
  • sh sbcl.run filename.fasl



Now the hard part begins..., Enjoy Lisp programing !

 

Sources

Stackoverflow







No comments:

Post a Comment