Re: Syntax, expressiveness and the beauty of Tcl
- From: Stephan Kuhagen <nospam@xxxxxxxxxx>
- Date: Mon, 30 Oct 2006 13:21:16 +0100
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
.
- Follow-Ups:
- Re: Syntax, expressiveness and the beauty of Tcl
- From: Larry Smith
- Re: Syntax, expressiveness and the beauty of Tcl
- References:
- Syntax, expressiveness and the beauty of Tcl
- From: Stephan Kuhagen
- Re: Syntax, expressiveness and the beauty of Tcl
- From: suchenwi
- Re: Syntax, expressiveness and the beauty of Tcl
- From: Stephan Kuhagen
- Re: Syntax, expressiveness and the beauty of Tcl
- From: Donal K. Fellows
- Syntax, expressiveness and the beauty of Tcl
- Prev by Date: Re: Thoughts about the controversial {expand} feature
- Next by Date: ANNOUNCE: moodss-21.4
- Previous by thread: Re: Syntax, expressiveness and the beauty of Tcl
- Next by thread: Re: Syntax, expressiveness and the beauty of Tcl
- Index(es):
Relevant Pages
|