On Dec 11, 6:19 pm, Rich Hickey <richhic...@gmail.com> wrote:
> Yes, the critical point is that the text-based representation of code
> is completely secondary:
> (def x (list (list (symbol "fn") (vector) "Hello World")))
>
> (class (second (first x)))
> -> clojure.lang.PersistentVector
>
> (class (first (first x)))
> -> clojure.lang.Symbol
>
> x
> -> ((fn [] "Hello World"))
>
> (eval x)
> -> "Hello World"
>
> You could build code via Java calls to the Clojure lib:
>
> (import '(clojure.lang RT Symbol PersistentVector))
>
> (def y (RT/list (RT/list (Symbol/create "fn")
>                          (PersistentVector/EMPTY)
>                          (Symbol/create "Hello World")))))
>
> Parens, square brackets, #, "", etc are reader syntax for data
> structures. You could define a different reader and completely
> different text-based syntax for the language.
>
> The language syntax is defined in terms of data structures, not text,
> and in that respect doesn't have (text-based) syntax. The reader has
> text-based syntax for data.
>
> Rich

Ok, so it's fair to say the Clojure Reader has syntax.  I don't see
how this is fundamentally different than how Ruby works, for example:

http://www.igvita.com/2008/12/11/ruby-ast-for-fun-and-profit/

The clojure.lang.LispReader parses an input stream of text into a Java
Object, the same way that the Ruby parser parses code into an AST.

One nice thing I will say about the Clojure syntax, as in all lisps,
is that is there are no reserved words.  Most languages, Java, Ruby,
Python, JavaScript, etc. have whole list of words you can't use for
variables.  This is cool:

user=> (def def 4)
#'user/def
user=> def
4
user=> (def x 5)
#'user/x
user=> x
5

Stuart, this might be a good point to mention in the book, in that you
will never see a page like these for clojure:

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
http://www.zenspider.com/Languages/Ruby/QuickRef.html#3
http://www.python.org/doc/2.5.2/ref/keywords.html


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to