3 ms·
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 i
by JohnDeHope 4y ago
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".
- catach 4y agoI find this is a good explainer: https://wiki.tcl-lang.org/page/everything+is+a+string https://wiki.tcl-lang.org/page/everything+is+a+string
- tyingq 4y agoThe page on the lack of "null" kind of goes with that as well: https://wiki.tcl-lang.org/page/null https://wiki.tcl-lang.org/page/null
- tptacek 4y agoLots 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.
- RHSeeger 4y agoIn 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.
- onedognight 4y agoThe 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 https://man.archlinux.org/man/Tcl.n.en
- deleted 4y ago[deleted]
- wernsey 4y agoYes, 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 http://antirez.com/articoli/tclmisunderstood.html [1] http://oldblog.antirez.com/post/picol.html http://oldblog.antirez.com/post/picol.html