On Dec 11, 5:03 pm, Daniel Eklund <doekl...@gmail.com> wrote:
> > I've been reading the latest chapter from Stuart's book, Chapter 7:
> > Macros, and he makes this statement:
>
> > "Clojure has no special syntax for code. Code is simply Clojure data.
> > This is true for normal functions, but also for special forms and
> > macros. Consider a language with syntax, such as Java. ..."
>
> > It seems to me that just like all lisps, Clojure has syntax. The
> > first and most obvious piece of syntax is the parenthesises. Lists
> > start with an open paren and end with a closing paren. This is syntax
> > and you can't change it with a macro.
>
> I would agree with you, but I do not feel too strongly about the
> matter. The statement "clojure has _no_ syntax" is probably not
> defensible with an eye towards formal rigor.. I have no idea what a
> syntax-less language would look like. I feel fairly certain that the
> book's aims are not to provide a hard stance on no-syntax but to open
> the eyes of those people who have been dealing with the Java's and the
> C's for their entire careers, where syntax is locked in by convention
> and grammar specs.
>
> Despite quote and {} and [] being syntax-tic sugar, they certainly
> have their sexp counterparts, and all of this is driven from the
> reader which could possibly be extended or reduced for particular
> needs -- although Clojure does not allow for programmer-defined
> reader macros (unlike other lisps).
>
> The existence of the reader makes the "no syntax" claim a lot easier
> to understand, but in the end, this could be a long discussion about
> what each person feels "syntax" is.
>
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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---