In other languages, not Lisps, parenthesis are normally used to group operators and so are optional in many cases. But in Lisp parenthesis are always meaningful. There may not be extra or optional parenthesis.
Most often parenthesis around expression mean function or macro application:
(foo 1)
Two parenthesis at the start of expression in such a case may occur, for example, when the first element of expression is another expression, that is evaluated to a function itself. For instance, imagine function make-adder
, which takes a number and returns another function with partially applied addition (btw, it's an example of currying):
(defun make-adder (number)
(lambda (another-number) (+ number another-number)))
We can create function variable increment
this way, and then apply it to variable:
(defvar increment (make-adder 1))
(increment 5) ; ==> 6
but we can also call it directly (ok, this will not work in Common Lisp, but same syntax works in other Lisps, called "Lisp-1", so I believe it's worth to mention it here) :
((make-adder 1) 5) ; ==> 6
making double parenthesis at the beginning. And, of course, both parenthesis are mandatory.
And one final case, which describes your situation, is when the language or user macro uses list of lists for its purposes (do you still remember, that Lisp program is itself a list of lists of expressions?). For example, defun
knows, that its 1st argument must be a symbol, and its 2nd argument must be a list. And labels
macro knows, that its 1st argument must be a list of definitions, each of which is a list itself. It was made to allow user to define more then one label at a time:
(labels ((definition-1) (definition-2) ...)
(do-this) (do-that) ...)
So, you can see, that each parenthesis mean something and you cannot drop them on your own.
(2+3)*5
would be written(* (+ 2 3) 5)
in lisp – Malia