Subject: [clisp-list] Pure LISP?

From: Miguel Gonçalves <[email-masked]>
Date: Wed Jan 2 02:50:04 2002

Hello!

I am starting out with Common Lisp and I have a question:

Does pure LISP include sequential calls to functions, i.e., 
(progn f1 f2)?

I can write the previous function as 
((lambda (p) f2) f1) also that is similar in a mathematical language
to f2(f1) and therefore LISP evaluates f1 first.

How can I write sequential code in LISP without this? In particular I
have a function like this:

(defun terminate (connection message)
  (progn
    (close connection)
    (format t "~s~%" message)
    (exit 1)
  )
)

Can I use thee following construction?

(defun terminate (connection message)
  (exit (format t "~s~%" message (close connection)))
)

TIA,
Miguel Gonçalves

---
I do not read proprietary document formats such as MS Word or MS
Excel, so send my files in ASCII, PDF, PostScript, XML, HTML, TeX 
or LaTeX.

---

From: Florian Weimer <[email-masked]>
Date: Wed Jan 2 03:12:04 2002

> to f2(f1) and therefore LISP evaluates f1 first.

In "pure LISP" (for reasonable definitions of "pure"), the order of
evaluation of expressions does not matter.

---

From: Sam Steingold <[email-masked]>
Date: Wed Jan 2 06:49:02 2002

> * In message <[email-masked]>
> * On the subject of "[clisp-list] Pure LISP?"
> * Sent on Wed, 2 Jan 2002 10:45:19 +0000
> * Honorable Miguel Gonçalves <[email-masked]> writes:
>

general Common Lisp questions are best asked on news:comp.lang.lisp

> Does pure LISP include sequential calls to functions, i.e.,
what's "pure"?

> (progn f1 f2)?

CL has it.

> I can write the previous function as ((lambda (p) f2) f1) also that is
> similar in a mathematical language to f2(f1) and therefore LISP
> evaluates f1 first.

don't do it.
you write code for _people_ (including yourself) to read (the fact that
your code might get executed by a computer is almost an accident).
PROGN is more clear than the lambda expression for this.

>     (format t "~s~%" message)

hanging parens are ugly.

>   (exit (format t "~s~%" message (close connection)))

this happened to be valid in CLISP, even though it is not the same as
your first version (FORMAT returns NIL and not 1).

this is just fine:

(defun terminate (connection message)
  (close connection)
  (format t "~a~%" message)
  (exit 1))

-- 
Sam Steingold (http://www.podval.org/~sds)
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
Failure is not an option. It comes bundled with your Microsoft product.