This is quite basic question that started puzzling me recently while studying Lisp (and derivatives). I have read some Lisp books and web sites and this subject is somewhat obscured by other Lisp properties that seem to be having more meaning to the authors so they give them more attention. So I cannot find this subject in books and I have no one to ask to help me out figure it out, because I do not know anyone who 'speak' Lisp. So this forum seem to be appropriate place to ask.
Here's a question (explanation first):
Lisp program can be generally described as a list of s-expressions executed in sequence (in a file, including other source files loading). As far as I understand Lisp program generally looks like this:
(op data, data...)
(op data, data...)
(op data, data...)
(op data, data...)
(op)
.... ; presumably endless stream of s-expressions (like in 'repl')
whereby above s-expressions may take number of different forms (function definitions, variable declarations, branching and flow control etc...)
So, how come Lisp program is not defined as:
(program
(op data, data...)
(op data, data...)
(op data, data...)
(op data, data...)
(op)
... ; presumably append-able list of s-expressions
)
?
It would seem logical and natural that program is a list of s-expressions to execute (as it is already implicitly understood just looks like missing explicit list declaration).
Is there particular (design) reason why first form is used and not the second? ( Or reasons are completely historical? Or ?)
Thank you!
(...)
can be given to the REPL, the LISP interpreter.(program (...) (...) ...)
is not different from a single(op ...)
. So the reason is the interactiveness of a command line interpreter. – Joop Eggen Jul 2 at 13:21main()
in other languages? – candied_orange Jul 2 at 13:27