• magic_lobster_party@fedia.io
    link
    fedilink
    arrow-up
    20
    ·
    20 hours ago

    I opened a TCL script once. It’s use of uplevel scared me. I’ve never dared to return since.

    For those who don’t know: uplevel is a command that goes up one level of the stack frame, and then executes code there. A function can therefore execute code in its callers stack frame.

    • lime!@feddit.nu
      link
      fedilink
      English
      arrow-up
      12
      ·
      edit-2
      18 hours ago

      tcl is pretty fun actually, it’s like bash on steroids.

      for a preview of the insanity: anything surrounded by "" is a string, with the variable expansion you’d expect. anything surrounded by {} is also a string, but with no expansion. the equivalent in bash is the backtick string. but you don’t need to know that to write tcl. if you approach {} as “code blocks” like in other languages, it just works. reason being that tcl evals everything, constantly, attaching little tags to strings that tells the language how things are used, like “this string is an integer” or “this string is code and here is the result from last time it ran”. it’s madness and, weirdly, robust as hell. Xilinx writes all their tooling in tcl. SQLite started life as a tcl module, and it’s still the only api that is not provided by a plugin.