in lisp, constants are variables that never change their values during program execution. constants are declared using the defconstant construct.
example
the following example shows declaring a global constant pi and later using this value inside a function named area-circle that calculates the area of a circle.
the defun construct is used for defining a function, we will look into it in the functions chapter.
create a new source code file named main.lisp and type the following code in it.
(defconstant pi 3.141592) (defun area-circle(rad) (terpri) (format t "radius: ~5f" rad) (format t "~%area: ~10f" (* pi rad rad))) (area-circle 10)
when you click the execute button, or type ctrl+e, lisp executes it immediately and the result returned is.
radius: 10.0 area: 314.1592