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: Will TCL release the variables automatically when the procedure is finished?
    ... it is NOT possible to "do too much float point math ... using Tcl": there are very large, ... If I were a betting man, I'd wager that namd is violating Tcl's threading principle: "an interp may only be called from the thread that created it". ... Also "As long as tcl doesn't do any floating point math in your script, this crash can't happen". ...
    (comp.lang.tcl)
  • 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: Will TCL release the variables automatically when the procedure is finished?
    ... I think the problem might be that I'm doing too much float point math ... I read this "there is a bug in the tcl interpreter (not ... have have been doing abundant floating-point calculations ...
    (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)