So this will not be a very formal definition of "form", but I will do my
best. A "form" is a fully contained "thing". So yes 1 is a form, so is "1",
and ["1" 2] and (quote (foo bar)), and {:foo :bar}. You are right in
assuming that reading a ( will cause the reader to read to the matching ).
This is why lisp parsers are most commonly "recursive descent" parsers.
Reading a list can be thought of:
1) is the current character a "("
2) is the next character a ")"?
3.a) if not return the current list
3.b) if so, read a form and add it to the list
4) jump to 2
As you can see, the parser is recursive in that it calls itself as it
descends into the forms in the file.
Timothy
On Sun, Dec 27, 2015 at 11:29 PM, Ray Toal <[email protected]> wrote:
> Throughout the Clojure documentation there are many references to *forms*.
>
> I know about special forms, macros, vars, symbols, keywords, integers,
> doubles, ratios, sets, maps, lists, vectors, booleans, nil, etc.
>
> What exactly, though, is a form? The documentation for the reader says:
>
> One might say the reader has syntax defined in terms of characters, and
> the Clojure language has syntax defined in terms of symbols, lists,
> vectors, maps etc. The reader is represented by the function read
> <http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/read>,
> which reads the next form (not character) from a stream, and returns the
> object represented by that form.
>
>
> This is fine, but what exactly is the "next form" referred to here? If the
> next available character in the stream is a left paren whose closing right
> paren is all the way at the end of the stream, is the next form read the
> whole stream? If so, does it not also read all of the nested forms?
>
> I've not been able to find a precise definition of a form, so any pointers
> will be appreciated!
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.