Re: Syntax, expressiveness and the beauty of Tcl



The point is, that it resembles the Tcl way better and is easier to
explain. In LISP, everything is prefix, so the (+ a b) is no surprise.
Tcl is similar regarding prefix operators. [expr] is the prefix
operator for math but inside it mixes infix notation in - which
differs from the philosophy of prefix operators that you have
everywhere else in Tcl.

I think having the math operators in their own namespace is a great
idea, especially if they take multiple arguments (eg. [+ 1 2 3 4 5]).
I've occasionally found it handy to have the basic maths ops as
commands, and having them pre-defined in the math ops namespace means I
don't have to re-define them myself anymore.


I also dislike it, because it introduces so many new commands and
will not stop to extend (and floating the namespace) with new
commands until all possible math expressions are included.

I've also rarely came across a situation where it matters if they're
stuck in their own namespace, because generally the [expr] command does
the job better anyhow. We'll probably run into that old [expr] problem
with double-evaluated arguments. So [tclmath::+] (or whatever it ends
up being) shouldn't often be a problem. And even when it is, you can
also quite easily pull just the ones you need into the local
namespace. People should be encouraged to leave room for these
operators, and pull them in from there rather than re-implementing them
themselves. Perhaps even provide a convenience function to do it.


Fredderic
.



Relevant Pages

  • Re: Hypothetical: All code in classes but main()
    ... >>gain access to member data and potentially become bound to it. ... >>the argument Stroustrup gives for having helper functions at namespace ... I have heard some Java wags claim that for performance ... Then I click on the "math" namespace, and the box refreshes, now ...
    (comp.lang.cpp)
  • Re: Hypothetical: All code in classes but main()
    ... the argument Stroustrup gives for having helper functions at namespace ... If a function requires access to member data, then by all means make it ... > There are advantages to having the static Math class in Java. ...
    (comp.lang.cpp)
  • Re: Hypothetical: All code in classes but main()
    ... > all data members, if it needs to access private and protected instance ... > the use of public data members in good OO design. ... > namespace math in a namespace top? ...
    (comp.lang.cpp)
  • Re: the annoying, verbose self
    ... local/global variables, and function/method calls? ... creates a new namespace: ... "with math" creates a newer ...
    (comp.lang.python)
  • Re: 64-bit arithmetic in scripts?
    ... expr does 64-bit math by default. ... If you want your script to work on both, you'll have to do a feature ... calling expr, and finally fall back on calling bc. ...
    (freebsd-questions)