[HN Gopher] Why is Tcl syntax so weird (2013)
___________________________________________________________________
Why is Tcl syntax so weird (2013)
Author : blacksqr
Score : 28 points
Date : 2021-11-07 20:44 UTC (2 hours ago)
(HTM) web link (wiki.tcl-lang.org)
(TXT) w3m dump (wiki.tcl-lang.org)
| [deleted]
| tracnar wrote:
| The Tcl wiki is quite strange, it has interesting content but
| most pages are discussions like this one and it's hard to find
| what's relevant or even correct.
|
| What's weird about the Tcl syntax is that there is barely any.
| It's very dynamic so only the top-level of a file is parseable as
| a list of commands, anything else like a procedure depends on the
| implementation of the command which can be overridden at any
| time.
|
| It's even used by built-in commands like expr and if which
| essentially implement a mini expression language which is
| different from Tcl.
| natrys wrote:
| I have been writing some Tcl for the last couple of years,
| mostly in place of shell scripts. Going to Tcl wiki is always a
| surreal experience. I think this old comment captured it
| perfectly:
|
| https://news.ycombinator.com/item?id=9098859
| kevin_thibedeau wrote:
| That's what wikis originally were. Wikipedia's curated ontology
| is an exception that only looks like the rule because most OG
| wikis have died off.
| emodendroket wrote:
| Emacswiki is one active one still like that and the effort to
| replace it with MediaWiki was ultimately abortive. C2 is also
| big but I think mostly dead.
| lilyball wrote:
| I've always loved Tcl because of its absolute purity and
| simplicity at the language level. I love how you can implement
| your own control flow operators that look like built-in ones. I
| love how easily you can make DSLs.
|
| I just wish there was a Tcl that was redesigned from a modern
| perspective. Give me first-class lambdas. Give me unnamed objects
| that get destroyed automatically (with a callback) when out of
| scope[1] so I don't have to use a weird namespace hack to make
| the object and rely on the caller to invoke the destroy method.
| Give me a stdlib that offers more functional stuff. Heck, give me
| async/await. And more too.
|
| But even without all of that, Tcl is still a wonderful language
| and I often lament how it's mostly died out.
|
| [1] There's at least one library I've used that actually does
| this, but AFAIK there's no way to do this in pure Tcl so it must
| be a feature of the C API. Also I'm not sure if it actually
| tracks the object or just the variable it's assigned to.
| potiuper wrote:
| Wonder if there is a compiler that will print
| 'string1'var1'string2'var2 with just adjacency?
| celeritascelery wrote:
| > Tcl is a macro language, it derives from macro-assemblers, the
| C preprocessor, and older, text-oriented languages like TRAC
|
| Then why doesn't it have macros? This is one of my biggest
| complaints with tcl, the other being that you have to escape
| newlines in forms. This makes much less pleasant then lisp.
|
| For example if I have this Tcl code
|
| [set foo [foofn bar [barfn baz [bazfn quz 1]]]]
|
| I would love to write it like this
|
| [set foo
|
| [foofn bar
|
| [barfn baz
|
| [bazfn quz 1]]]]
|
| But I can't without escaping every newline (you better hope you
| didn't forget one). If tcl had macros I could write it like this
|
| [set foo [thread-last 1
| [bazfn quz] [barfn baz] [foofn bar]]
|
| But instead I end up create a bunch of temporary variables so
| that my lines don't get super long. It just feels less elegant
| then it could have been.
___________________________________________________________________
(page generated 2021-11-07 23:00 UTC)