3 ms·
I have a hard time imagining that TCL would not have the same problem that PHP, Python and JavaScript have with types. If you're trying to add a string and a nu
by lolinder 5y ago
I have a hard time imagining that TCL would not have the same problem that PHP, Python and JavaScript have with types. If you're trying to add a string and a number, the language has to either throw an error or implicitly turn that into concatenation, propagating the string to more expressions that expected a number. At a cursory glance, it looks like TCL throws an error.
In that case, I can't imagine writing any significant amount of TCL and not having reached a point where you have a runtime error that would have been prevented had you had a static type system.
Am I missing something?
- massysett 5y agoMy guess is that Dr. Hipp’s (SQLite author) meticulous and prolific use of testing ferrets out so many bugs that the ones that are left wouldn’t be caught by static typing. In contrast, folks who rely heavily on static type systems may not write so many tests. For example I put more energy into making sure that my Haskell types capture the problem I’m trying to solve, so that the compiler flags my mistakes and exposes poor assumptions.
- kbr2000 5y agoI'd say the idea is that the implementation of a command/procedure needs to do the checking. In your example, arithmetic addition is usually provided by expr [0], which checks the expression it is fed before trying to calculate anything. When you would like to concatenate strings (including numbers), you would use quoting or commands/procs made for that purpose instead. [0] https://tcl.tk/man/tcl/TclCmd/expr.htm https://tcl.tk/man/tcl/TclCmd/expr.htm