Re: Syntax, expressiveness and the beauty of Tcl




Christian Gollwitzer wrote:

set x [expr $a+$b]

I also dislike expr in Tcl, if one has to do lots of math. Especially
that in 99% cases one needs to use additional braces. Set is OK. I'd
like to have a syntax like
[...]
set a ${$b+7}

That all looks very weird and complex. What about a simple and strict
polish notation, like in LISP:

proc + {a b} {expr {$a + $b}}
proc - {a b} {expr {$a - $b}}
proc * {a b} {expr {$a * $b}}
proc / {a b} {expr {$a / $b}}

set res [+ [* 7 8] [- 8 9]]
55

Every operator is a command as well and it is compatible with the rest
of Tcl (although it will be even less familiar to the majority of
programmers)


Eckhard

.



Relevant Pages

  • Re: "A string, or not a string", that is the question ;)
    ... doing math on a "string". ... Tcl belongs to a group of languages referred to as "dynamically ... Other languages that won't "balk" at doing maths on strings ...
    (comp.lang.tcl)
  • Re: About Tcl syntax...
    ... What do you dislike in Tcl the most? ... they need to do some math. ... Python with courtesy of Haskell.. ...
    (comp.lang.tcl)
  • Re: So slow Tcl :(
    ... >>Tcl is slow at math and more because Tcl has no efficient way to store ... One reason I turned to C in this particular instance was to make more ... pure-Tcl program relied too heavily on virtual memory). ... list accesses, and math operations. ...
    (comp.lang.tcl)
  • Re: tcl weaknesses
    ... > Do not worry about performance: yes, Tcl's math is slower than ... > developing number-crunching programs that run for hours to come ... In the end this point is generally a weakness in scripting languages, ... But there is a strength in Tcl - it is _very_ easy, ...
    (comp.lang.tcl)
  • Re: Simple maths question
    ... This was using Tcl 8.5a4. ... The real reason you get this result however is that floating point ... floating point math in binary. ... elaborate explanation. ...
    (comp.lang.tcl)