Re: Syntax, expressiveness and the beauty of Tcl



Donal K. Fellows wrote:

We'd really rather you didn't use ":" as the command name. Almost
anything else (including control characters!) would be better. This is
because "::" is used for a namespace separator and ":" on its own gets
tangled in that. It might be better to use something like this instead:

|- x=2+2

"|" looks strange to me. But the name of the extended expr command does not
matter, I was just playing around. I think, one could and should use that
character, that fits best with his thinking. I know ":" is for namespaces,
but it gave me the impression of some kind of prompting. Maybe ">" would
the be a better choice, since it is only one character.

The other problem with the syntax as it seems to be at the moment is
that not putting braces around it means that variable substitutions
happen at "the wrong time", meaning that they can change the sequence
of operators. (This was a common problem with [expr] usage in Tcl
scripts in the 7.* days, BTW.) There are ways to fix - e.g. treating
barewords as variable names - but they in turn reduce the ability of
your code to intermix smoothly with Tcl's basic syntax and you'll end
up having to put braces round things a lot anyway.

Yes, as I said, I was just playing around while waiting to get fully awake.
I did not wanted to create a full blown package for math expressions. For
that, there are many things missing in my tiny extension. The ":" thingy
was just for having a possibility to type simple math expressions in a way,
that looks "normal", when you are used to other programming languages. I
think, if someone really wants to use Tcl, he should use [set] and [expr]
anyway.

BTW, if you're going to do assignment, don't repeat BCPL's mistakes.
Use ":=" as the assignment operator.

I think, it is not a question of mistakes or not today, but what you are
used to. If this little extension is meant to be used by someone who never
programmed Pascal or something like that, but Python or other languages
using "=" for assignment, then "=" is a good choice. In my early days, when
I learned programming on a pocket calculator, I used one of the first
graphics capable Casio pocket calculators, which came with it's very own
kind of language. The assignment there looked like this:

2+2 -> x

I like that very much until today, it looks logical to me. So the syntax of
such an extension does not matter to me. The point was just my enjoyment of
Tcls flexibility in such things. As I said, just playing around while
waiting to get really awake...

But if we take the discussion serious, my oppinion is to stick with real Tcl
syntax anyway. Using [set] and [expr] is not only faster and better, it is
also "the Tcl way". Using some visually hidden proc ":" or ">" can make a
user think, that "=" is really some kind of assignment instruction and
leads to confusion. Its good for a simple user interface for math
expressions, but not for programming. What I really wanted to say and show
with that, was written in the remaining part of my OP: Tcl is fun and a
beauty of a programming language.

Regards
Stephan
.



Relevant Pages

  • Re: Why isnt "dash" a wordchar?
    ... identifiers in many programming languages. ... that Tcl is *not* one of them, but we can't all be conformists. ... allows just about any character in an identifier with careful bracing), ...
    (comp.lang.tcl)
  • Re: Why isnt "dash" a wordchar?
    ... identifiers in many programming languages. ... that Tcl is *not* one of them, but we can't all be conformists. ... allows just about any character in an identifier with careful bracing), ...
    (comp.lang.tcl)
  • Dr. Dobbs Tcl-URL! - weekly Tcl news and links (Jan 2)
    ... "As long as Tcl is number one in ease of use among general-purpose ... programming languages, it will have a clear future, no matter how many ...
    (comp.lang.tcl)
  • Re: Not a flame war--curious about Python vs. Tcl
    ... > have been giving Python a try. ... "I don't learn a language that does not change my way to think at programming". ... I suggest that programmers interested in new programming languages ... the few it really uses every day (Tcl and C for me). ...
    (comp.lang.tcl)
  • APLAS07 - Call for Participation
    ... The Fifth Asian Symposium on Programming Languages and Systems ... APLAS aims at stimulating programming language research by providing a ... APLAS07 will include a poster session. ...
    (comp.lang.ml)