Hacker News new | past | comments | ask | show | jobs | submit login

How I understand it is that Lisp has syntax but lacks a grammar, the syntax is just very simple. Essentially the same as Forth and Tcl, everything is either a command or data, a result of the simple single pass left right parsing. But I am not completely sure I have things right just yet.

Edit: What I am saying is that in lisp '(' is actually a command and everything after it is an argument to that command. The syntax is command - arguments; this is what gives these languages their power, the simple syntax and lack of grammar allows us to define our own grammar. Hopefully someone will correct me if I misunderstand, I could be seeing Tcl and Forth everywhere since I have been primarily working with them lately.




In Common Lisp, '(' is a macro character that triggers a reader macro to read/parse the list it surrounds with a pair ')'.

More info: https://gist.github.com/chaitanyagupta/9324402

This one demonstrates how what's read in can be parsed - sort of a "Lisp in Lisp" version of eval: https://stevelosh.com/blog/2016/06/symbolic-computation/#s11...


Most programming languages are defined in terms of program text, Lisp is not. Lisp is defined in terms of in-memory structures and what happens if you pass these in-memory structures to a hypothetic of actually existing function "eval".

With this way of viewing things your "( is actually a command" no longer is useful/ no longer makes sense. (I wouldn't say you're completely wrong, though, just that another view of things seems simpler to me.)

You could probably implement a Lisp with a scanner and a parser but things are a lot easier if you follow the traditional read-eval route (or preferably read-macroexpand-eval).


So I am just seeing Tcl and Forth everywhere. You go a bit over my head with your explanation but you have given me enough to sort this all out myself, pointed out a few gaps in my general understanding of things. Thanks.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: