4 ms·
The way I'm used to seeing the GP's example made is set a pu set b ts $a$b "Hello!" which I think does a better job showing how the mixture of str
by gecko 6y ago
The way I'm used to seeing the GP's example made is
set a pu
set b ts
$a$b "Hello!"
which I think does a better job showing how the mixture of strings with interpolation allows for some slightly unexpected things.
- Twisol 6y agoWould it be fair to call this a kind of "pervasive eval"?
- artemonster 6y agoyou've misspelled "evil" ;)
- adwn 6y agoYes, you're probably right. Frankly, I'd rather not have this kind or error-prone behavior in my programming languages, not even when scripting. It makes proper handling of strings hard and cumbersome (as evidenced by a lot of software that can't handle spaces in file names because it's calling scripts written in sh or bash), and I don't get the Tcl love professed in the comments here.
- setpatchaddress 6y agoI'm not a fan of Tcl -- I used it a bit in the 90's -- but this really isn't the best example. You need a bit more context to give it a fair shake.
- wryoak 6y agoYour attribution of "error prone behavior" to programming languages rather than to their users may explain why you "don't get the Tcl love"
- dleslie 6y agoThis is kind of clumsy in R5RS Scheme: ((eval (string->symbol (string-append "dis" "play"))) "Hello world")
- OJFord 6y agoGood lord, as an example of why it's something we should want? Each to their own of course, but..
- coldtea 6y agoFor example because it's kind of homoiconic. Since everything is a string you can define your own control flow constructs for example...
- adwn 6y agoIf you define your own, say, repeat-until loop, can you use the built-in break and continue commands? Could you define a break-with-value command for the built-in loops?
- dvdkhlng 6y agoUsing Tcl exceptions, I guess it would be pretty trivial to do that. Here [1] is an alternative do..while loop implementation provided by Tcllib, written in pure Tcl. [1] https://core.tcl-lang.org/tcllib/artifact/4f7e97706ff67a40 https://core.tcl-lang.org/tcllib/artifact/4f7e97706ff67a40
- ufo 6y agoI don't think this is the sort of code that people tend to write. But it does a good job of succinctly explaining how Tcl works.
- pgtan 6y agoin TeX: \def\a{mess}\def\b{age}\csname \a\b \endcsname {Hello there}\bye in (UCB)LOGO: ? run list word "pri "nt [Hello there]