All Lisp functions provide a result: for example, the function
+ returns the sum of its inputs. (By the way, inputs to
a function are sometimes called "arguments", or "parameters".)
Some Lisp functions also have a side-effect. For example, in the
Emacs-Lisp dialect (a form of Lisp used in the text editor Emacs)
there is a function called
insert, which you provide a
piece of text to, and it inserts it into the file you're editing.
(This would be used inside a "paste" command for cut-and-paste, for
Sometimes the result of a function is not particularly significant, if the function really just exists for its side-effects.
If you want your program to do a series of actions, you can wrap
them in a function-like thing (technically, a "special form" -- I'll
explain the difference later) called
progn, which is an
abbrevation for "program n" -- the n means that the result of the
progn form is the result of the last part of it.
For example, to insert "hello" at the start of a file, you could
(progn (goto-char 0) (insert "hello"))
By the way, the division of the program into lines, and the spaces in the margin, are just convention for human readability, and don't make any difference to the Lisp system.
|John C. G. Sturdy||Last modified: Thu Nov 1 14:56:57 GMT 2007|