2014-02-12 5:36 GMT+01:00 Di Xu <xudi...@gmail.com>: > > all lisp dialect provide `read` function, so if you want to build an > evaluator, you could just use this function and don't need to do lexical > and syntax analysis. >
Maybe your understanding of these terms is different from mine, in my view: A lisp evaluator needs to do syntactic and lexical analysis. Those are both performed after the data structures have been parsed by `read` and then macroexpanded by the compiler. Macroexpansion could be considered part of syntactic analysis for most macros. Read doesn't do any analysis at all. Usually it's completely independent from language semantics. In clojure, there is a slight complexion in the form of syntax-quote (`) which uses the compilation environment to determine symbol namespaces. # Example ;; this is the primitive let* form, to which let macroexpands (let* [a (init a b c)] (process a)) Both kinds of analyses (syntactic, lexical) have to be done by every compiler or evaluator at some point. Compilers tend to do it during compile time. ## Syntactic Analysis: Here syntax analysis mandates that the second parameter is a literal vector with (mod ... 2) elements and a symbol w.o. namespace as every second element. If this condition is not met, the compiler can and should fail with a syntax error ## Lexical Analysis: Lexical analysis will try to resolve the names `init`, `process`, `b`, `c` to either their innermost lexical bindings or namespace vars or refers. The outer `a` that `init` is called with, is also resolved to an outside binding. The inner `a` (argument to `process`) is always bound to it's (lexical) rebinding in the let* form. In this phase, unbound-name errors are thrown if the analyzer can't find the origin of a binding. hope someone finds this nitpick useful kind regards -- 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 Note that posts from new members are moderated - please be patient with your first post. 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 --- 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.