|
Topics
|
|
Introduction
LISP is part of the class of functional languages.
LISP = LIStProgramming.
Short introduction: LISP history
LISP was invented by John McCarthy in the late
1950's, as a formal model for the calculus of recursive equations. Did you know that the only programming language older than LISP that is still used is Fortran?
McCarthy characterized the language in 1980 :"LISP has survived 21 years, because it is an almost optimal choice in the field of programming languages.
The reputation of LISP is helped by its strong theoretical foundations – functional form; , lambda calculus and usage of generalized functions.
First steps:
- 1956 – McCarthy developed a language for algebrically processing lists, with the purpose of using it in matters related to artificial intelligence
- Between 1960-1965 the main dialect was Lisp 1.5
- in the beginning of the 1970's there were two dialects: MacLisp
and Interlisp.
Maclisp was developed from Lisp 1.5 by adding special variables,
and treating errors, such as the concept of functions
with variable number of arguments, macrodefinitions, matrices, etc.
Iterlisp introduced several new concepts, such as iterative construction
, adopted also by MacLisp and later on by CommonLisp.
- In 1981, based on a DARPA project by combining several projects
Common Lisp was obtained as a description of a family of languages
- In 1986 ANSI Comon lisp resulted in a new specification of language
with the definition of portability, object-oriented programming, conditions systems, etc.
Emacs
Emacs is an adaptable and expandable editor. It is based on a LISP interpreter
, elisp, a dialect of the language Lisp.
Characteristics:
- modes (major modes) of work for a wide range of languages
- online documents
- expandable through the language Emacs Lisp
- support for different languages (natural and programming)
The laboratory will use the program editor Lisp interpreter and Emacs environment and package programs XLisp-stat.
For Emacs commands read the summary of useful keys.
You can find details at GNU
Emacs Manual.
Starting emacs and lisp
Using Linux
Action |
Result |
Start a terminal (screen icon) |
The terminal window appears |
Type emacs & |
Emacs is starting |
Press C-x 2 |
The current window is split in two identical windows |
Press C-x o |
The second window is activated |
Press M-x run-xlispstat |
XLISP-STAT is starting |
Press C-x o |
The first window is activated |
Press M-x lisp-mode |
Emacs enters the inferior lisp mode |
Type a LISP line for testing |
For example (+ 1 2) |
By positioning the cursor over an element between the paranthesis introduced
press M-C-X |
In the lisp window the result 3 will appear. |
Using Windows
Action |
Result |
Select the icon XLisp-Stat on Desktop |
XLisp-Stat is starting |
Minimize XLisp-Stat |
The application will minimize (the server application will be called by Emacs) |
Select the icon Emacs from Desktop |
Emacs is starting |
Press C-x 2 |
The current window is split in two identical ones |
Press C-x o |
The second window is activated |
Press M-x run-xlispstat |
XLISP-STAT is starting |
Press C-x o |
The first window is activated |
Press M-x lisp-mode |
Emacs enters the inferior lisp mode |
Insert a lisp line for testing |
For example (+ 1 2) |
By positioning the cursor on one of the elements between the paranthesis
press M-C-X |
The result 3 will appear |
Important keys in Emacs
The following table is a summary of the important key combinations
assigned to different commands in emacs.
In the table C represents the key Control, whereas
M represents the key Alt or Meta.
For example C-x 2 indicates pressing the keys at the same time
Control and 2, followed by pressing the key 2 (without
Control!)
Key combinations |
Effect |
C-_ |
Undo |
C-x 2 |
Clone windows |
C-x C-n |
New buffer |
C-x o |
Switch active window |
C-x k |
Kill the buffer |
C-x b |
Selecting the current buffer |
C-x C-s |
Saving the current buffer |
C-x C-w |
Saving the buffer with another name |
C-x C-f |
Opening a file in a buffer |
C-x C-c |
Close emacs (with saving) |
C-SPC or C-@ |
Positioning the selection point |
C-x C-x |
Interchanging selection point |
M-w |
Copy |
C-w |
Cut |
C-y |
Paste (yank) |
C-s |
Cautare(search) in the buffer |
C-M-x |
Evaluation with the internal Lisp interpreter, in case xlisp-stat
is not started |
C-M-x |
Evaluating xlisp-stat (only if xlisp-stat is
open in the activ lisp mode) |
C-u-n |
Repeating n times a simple command |
C-x z |
Repeating the last command |
C-g |
Renouncing an unfinished operation (which awaits another parameter) |
M-x |
Extended commands that do not have assignated key combinations |
M-x lisp-mode |
Transfers the current buffer in the lisp mode, necessary for interpreting the combination C-M-x |
M-x inferior-lisp-mode |
Transfer the current buffer in the inferior-lisp mode, in case the mode was changed by mistake |
Problem |
Practice:
- Creating a buffer
- Inserting a text
- Selection operation and copy-paste
- Saving a buffer
- Reloading a buffer
- Evaluating a lisp expression with lisp-stat (+ 1
2 3)using the incorporated interpreter
- Starting emacs and xlisp-stat
- evaluating a lisp expression with xlisp-stat
|
Notă: Activitatea la acestă ora de laborator
nu se va finaliza printr-o notă, ca activităţile urmatoare,
Îincepând cu laboratorul 3 necunoaşterea operaţiilor
de bază emacs şi xlispstat implică nota 4
la toate lucrările de laborator în termen şi încă
nepredate!
Installing emacs and xlispstat
Sub Linux
Redhat 6.2
- Install(during the installation of Linux) the packages emacs
and xlispstat
- Copy the file .emacs
in the home directory of the user
- Configure in .emacs the directory where xlispstat is
Redhat 7.3
- Install Linux
- Save the precompiled xlispstat version from here.
- Unarchive the root .tar-ul obtained in the root folder.
- You have to relocate /home/student/.emacs.
In the home directory of the user you work with
, in case you want to use xlispstat
with a user differen from student.
Installing with other versions
- Obtain the source code from ftp://ftp.stat.umn.edu/pub/xlispstat/3-52/xlispstat-3-52-20.tar.gz,
- Unzip the archive.
- Follow the installation instructions from the file
Install:
- run: configure
- run: make
- run: make install
- Copy the file .emacs
in the home directory
- Copy the file xlispstat.el
in the directory /usr/local/etc
Sub Windows
- Save the last distribution of emacs. The archives can be found at the
address http://ftp.gnu.org/gnu/windows/emacs/,
the versions precompiled for the Windows system contain
in the name of the file i386. At the current moment
the most recent precompiled version is at aici
or on the local website.
- Unzip the archive tar
in the directory c:\cflp (the following directory will be created
c:\cflp\emacs)
- Create a link towards desktop c:\cflp\emacs\bin\emacs.exe
- Save xlisp-stat for Windows from ftp://ftp.stat.umn.edu/pub/xlispstat/.
The most recent version (3.53.17 ) from ftp.stat.umn.edu
or the version locală.
- Copy the executable Wxls32zp.exe in the
directory c:\cflp\xlispstat and start the unpacking.
- Create a link on the Desktop towards c:\cflp\xlispstat\Wxls32.exe
- Set the environement variable HOME at the value
c:/cflp/
- Copy the file .emacs in the
directory c:\cflp
- Copy the file xlispstat.el
in the directory c:\cflp
- Done! You can now test lisp!
Useful links
GNU Emacs
Manual - a good description of the lisp commands
The XLISP-PLUS Home Page
Istorie Lisp
- lisp.org
Istorie Lisp şi famili
de limbaje lisp
GNU
Emacs Lisp Reference Manual - Unix
GNU
Emacs FAQ For Windows 95/98/ME/NT/XP and 2000
Implementă ri
Lisp
Implementă ri
comerciale
Problems
Problem 1. Getting familiar with emacs and xlisp-stat
Problem 2. Installing emacs and xlisp-stat
(optional, as homework)
|