Inline return values

On Jul 1, 7:44 pm, Kaitzschu
<kaitzs...@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
On Tue, 1 Jul 2008, dave.joub...@xxxxxxxxxxxxxx wrote:
On Jun 30, 12:35 pm, Kaitzschu
set tl [lrange [split [read $in] \n end-[incr n -1] end]

As an aside, I found myself shocked at the thought that one could use
incr that way!


There has been some tangential discussion using "inline return values" on
tclcore mailing list regarding [chan pipe], but I guess this doesn't
really apply since using a "mutator" command this way is most likely going
to result in an error, as you point out with your scenario.

But I like it! Even if it is going to put a nail to my foot sometimes :)

Ah yes, for "casual" programming tasks I also like (ab)using return
values of commands. I especially like that [set] always returns a
value. My favourite (ab)use is the "slurp" one-liner:

set data [read [set f [open $filename]]][close $f]

Of course, in production code it's not a good idea to do this.