Re: Syntax, expressiveness and the beauty of Tcl



On Mon, 30 Oct 2006 15:33:52 +0100,
Christian Gollwitzer <Christian.Gollwitzer@xxxxxxxxxxxxxxx> wrote:

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: ${something}
as an equivalent to [expr {something}]
So one could write: set a ${$b+7}

Question... Any reason it couldn't be adapted to a syntax like:

set a ${{$b+7}}

ala bash shells in *nix? The ${{...}} structure doesn't do what it
looks like it'd do anyhow. One would incorrectly assume that it would
either resolve a variable whos name contains the inner brackets, or
that the inner brackets would be magically absorbed as some kind of
list-of-a-single-word thing. In actual fact, the first open-brace
matches the first close-brace, with the effect that the second
open-brace is considered part of the variable name, and the second
close-brace is literal. This would be a very ugly variable name to try
and work with at the best of times.

So adding support for ${{...}} being equivalent to [expr {...}], might
actually make the syntax cleaner and slightly less confusing than it
already is anyhow, by giving it an actual defined meaning.


Fredderic
.



Relevant Pages

  • Re: Compound conditionals
    ... > What's the syntax for compound conditionals? ... > parentheses but they produce syntax errors like "expected boolean value ... If uses the same rules as the command expr. ...
    (comp.lang.tcl)
  • Re: regular expression
    ... Statement Modifiers ... unless EXPR ... > the CPAN docs don't include deprecated syntax. ... It is NOT deprecated syntax. ...
    (comp.lang.perl.misc)
  • Re: Syntax via macro characters.
    ... So I would like to have the syntax interpreted ... (funcall *typed-expander* expr type))) ... (declare (ignore dash)) ... ;; macro definition goes here. ...
    (comp.lang.lisp)
  • Re: About Tcl syntax...
    ... time and redesign Tcl from scratch I'd leave both while and for out ... I'd include syntax for [expr] as a higher priority than say syntax for arrays. ...
    (comp.lang.tcl)
  • Re: How to dynamically pass operators to if?
    ... of operands only, not operations or other syntax. ... At least as long as I've been using Tcl, the [expr] parser wants ...
    (comp.lang.tcl)