Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I know TCL has an interesting story about how the syntax is basically all embedded strings, or something. Does anyone know if it has a recursive structure, as in lisp? Maybe it's more of an "everything is an X" structure, as in forth where everything is a "word".


The entire grammar is spelled out in the tcl(n) man page[0]. It’s amazingly concise and easy to learn from just this. To answer your question, it’s “as if” everything was a string, but the implementation is reasonably efficient and doesn’t convert all the time.

[0] https://man.archlinux.org/man/Tcl.n.en


Yes, in Tcl everything is basically a string, but has Lisp-like recursive structures: An expression like `{foo {bar baz}}` evaluates to the string "foo {bar baz}" at first, but then that might be split into two strings "foo" and "bar baz" by the interpreter.

I recall Tcl being described as a Lisp without the parenthesis many years ago, which I still think is somewhat apt.

Antirez' article "Tcl the Misunderstood" [0] is well worth a read if you want to know more.

He also has an interpreter, Picol [1], in 500 lines of C code that is very easy to read and to understand.

[0] http://antirez.com/articoli/tclmisunderstood.html

[1] http://oldblog.antirez.com/post/picol.html



The page on the lack of "null" kind of goes with that as well: https://wiki.tcl-lang.org/page/null


Lots of people say Tcl is homoiconic. It can feel pretty lispy if you want to code that way, since evals and uplevels work a little like macros.


In my mind, Tcl _is_ a lisp. Admittedly, it's pretty far out on the family tree branches, but the overall structure feels very lispy to me.




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

Search: