| Andreas Leitgeb 2006-10-31, 4:01 am |
| Fredderic <put_my_name_here@optusnet.com.au> wrote:
> Oh, there is one point that just came to mind. There's talk of
> extending the end-n notation in [lindex] and [lrange] (and others) for
> general substitution and offset. It's mostly in the spirit of those
> changes that I originally started arguing this thread.
>
> I likewise appreciate the idea, and will most certainly find it very
> useful, but am none the less hoping [lindex] doesn't start supporting
> $a-$b*$c+$d as its index. :)
Afaik, this is limited to single "+" and "-" operations with
possibly signed arguments. e.g -5+42, 2--4, ...
There are two things I'd like to see for lrange:
1.) allow to give more ranges, that are concat'ed
[lrange {a b c d e} 0 1 3 4] -> {a b d e}
2.) allow "relative" end-indices:
[lrange {a b c d e} 2 s+1] -> {c d}
"s" being an anchor like "end", but referring to the
previously given start-index. Based on my own code,
this would not only save lots of [expr]'ing already,
but also lots of intermediate saving to vars:
set v [...]; ... [lrange $list $var [expr {$var+42}]];
PS: this subthread is no longer about tcl-syntax.
|