6 ms·
Schrödinger’s Tcl – Values that differ if you look at them
- nickodell 9y agoThis is an impressively bad idea. Good work.
- myrandomcomment 9y ago+1, up thumb or whatever the current thing is. Having spent my life in networking tech, Tcl...please die.
- frozenport 9y agoPerhaps they choose TCL to emphasize this point.
- zwischenzug 9y agoTCL was the chosen language of the company we worked for at the time. I tempted the author to join my team, and we collaborated on the book 'Docker in Practice' while implementing Docker within that company 2013-2015, before we both left. TCL is an unreasonably effective language for certain use cases (the company we worked for were driven by extremely tight deadlines and high performance requirements (appserver written in pure C in late 90s, with call-outs to TCL for business logic). I haven't touched TCL since, though.
- frozenport 9y agoI've found Python, LUA, or anything else better from an end-user perspective. Integrating Python can be hard, but TCL vs LUA?
- athom 9y agoActually, once I read what he REALLY seemed to be shooting for, I think it might actually be a GREAT idea! Let's say you want to process a list of numbers, a set of data records, or something fairly complex. Internally, you can pass it between functions in a fairly compact, but almost illegible form. If a human user wants to see what's getting passed around, though, it could be handy if the system could automatically transform it to smoothing more human readable: tabulated, indented, pretty-printed, what-have-you. I could definitely see a use for this, strange as it might seem.
- zwischenzug 9y agoThis guy's done many impressive things: https://aidanhs.com/ https://aidanhs.com/
- lngnmn 9y agoYet another popular hipster's nonsense. Observer affects an observation by interpreting it in a wrong context, which includes observer itself and non-existent relations he implicitly produces. There is nothing else here, not even a paradox. An observer delude himself by including products of the mind into "an equation".
- jamesdutc 9y agoI can do this in Python with my `rwatch` module. >>> from datetime import datetime >>> x = lambda: f'{datetime.now()}' >>> x <function <lambda> at 0x7f9f435e4510> >>> x() '2017-09-17 02:14:12.834957' >>> from sys import setrwatch >>> setrwatch({id(x): lambda f, o: o()}) >>> x # look, ma: no parens! '2017-09-17 02:14:16.306198' >>> x '2017-09-17 02:14:17.734965'
- zwischenzug 9y agoI'm not sure how that is 'the same'?
- aidanhs 9y agoOne thing that may be non-obvious to people unfamiliar with Tcl is that it's syntactically a shell-like language, i.e. functions are invoked with a space-separated list of arguments and no parens. So `schro` on a line by itself executes the function and `[schro]` is equivalent to `$(schro)` in shell.
- tyingq 9y agoOnly when you're using the REPL. They call it "interactive mode". [ls], for example, will generate an error if you put that in a tcl script run non-interactively. Another common cause can be the difference between interactive and command modes for Tcl. When you start up a Tcl interpreter, get a prompt, and type in commands to Tcl, this is called interactive mode. In this mode, Tcl does a few extra things for you. For instance, if you type ls, and you have no proc called ls defined, Tcl will try to exec a command called ls. This sometimes misleads a new Tcl user into thinking that Tcl has ls defined." [1] [1] https://wiki.tcl.tk/1630 https://wiki.tcl.tk/1630
- tyingq 9y agoSomewhat related, for Perl: http://search.cpan.org/~dconway/Quantum-Superpositions-1.03/lib/Quantum/Superpositions.pm http://search.cpan.org/~dconway/Quantum-Superpositions-1.03/...
- forinti 9y agoI used this for my Quantum Countdown Sort: http://alquerubim.blogspot.com.br/2011/10/quantum-countdown-sort.html http://alquerubim.blogspot.com.br/2011/10/quantum-countdown-...
- zerr 9y agoIf I understand correctly, that looks like a cheating. I'd expect this to be done purely in Tcl, without diving to C-level.
- zwischenzug 9y agoI believe the point is that the bytecode 'knows' the context the value will be delivered to, which is the interesting thing that separates this from most other languages. From the README: This is somewhat interesting. You can't use frames to differentiate between puts [schro] and schro, as they're both in the same frame. In fact, in the general case for a programming language, this is impossible - it would depend on using an oracle to predict what's going to happen to the value you return. Happily, in Tcl we can cheat! There are three vital points - 1. Tcl compiles lines passed into the repl to bytecode, 2. Tcl bytecode is a stack machine and 3. Tcl has a pointer to the current execution location in the bytecode (note that point 1 only became true in Tcl 8.6 (I believe) so this code won't work before then).
- aidanhs 9y agoAuthor here: doing this in any language is probably going to depend on some implementation details of the language repl, which may require dropping down to a level where you have access to these internals - for example, I can't think of a way you could achieve it in strict mode JS. Python may well be able to do it with just the stdlib since it has excellent debugging capabilities, but Tcl is relatively weak. You might be able to do something with `tcl::unsupported::getbytecode` and checking the frame level, but this was just a throw-away novelty so I'm not particularly motivated to find out.
- Darkenetor 9y agoAlas, for JS function.caller on a getter isn't standard but will work everywhere and should do it.
- tyingq 9y agoI don't think it's that easy. If the context is making javascript output something different in it's REPL for just "foo" vs "console.log(foo)", there's other pieces you would need. Like overriding a built-in type and getting function.caller into valueOf(). As far as I can tell, JS doesn't let you just tweak valueOf(), you would have to re-implement all of, for example, the String class.
- deleted 9y ago[deleted]
- yodsanklai 9y agoUnrelated but genuine question: what's the appeal of Tcl nowadays? are there applications where it'd make sense to use Tcl?
- forinti 9y agoWith freewrap, you can make a standalone executable for Windows. You won't need to install a VM on your user's machine. The last app I built like this was a graphical front-end for joining PDF files with Ghostscript (choose files, choose destination, press go).
- ghettoimp 9y agoIt's a truly awful language. For some reason it's used by a lot of CAD/EDA tools (hardware development), so if you're working in that ecosystem it's often all you've got.
- slrz 9y agoRight, Tcl is the lingua franca of EDA tooling. People just expect that you can talk to it via Tcl. It's often the only way to automate design flows, so you better get used to it. Tcl is actually pretty decent as a language, very elegant in its utmost simplicity. I don't get the bashing here.
- ghettoimp 9y agoI didn't realize that this would come across as senseless bashing. My main complaints against TCL basically center around the everything-is-a-string mentality and the corresponding lack of type safety anywhere. A more minor objection is that I strongly dislike the syntax for numerous reasons, such as - Comments aren't like any other language and have numerous gotchas, e.g., you can't use mismatched {}s in a comment within a proc, - Whitespace is relevant in surprising ways, such as requiring Egyptian brackets for procs/ifs, and I constantly forget line continuations - Using foo for lvalues but $foo for rvalues, while sensible, is a constant source of typos... but, of course, you do get used to it. Mostly. But the comment thing really irks me. I will certainly agree that you can do worse. TCL is surely a fine alternative to awful shell languages (bash, C shell, etc.) But in the realm of dynamically typed scripting languages, I'd absolutely nominate Python or Ruby as a much more reasonable and sensible for your everyday programmer, and Lisp's S-expressions seem far more elegant if you insist on a unifying principle like everything-is-a-...
- devdoomari 9y agowow this is a super troll idea... getters that change value... muahahaha