Inline return values
- From: "slebetman@xxxxxxxxx" <slebetman@xxxxxxxxx>
- Date: Tue, 1 Jul 2008 18:25:52 -0700 (PDT)
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!
<snip>
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.
.
- Follow-Ups:
- Re: Inline return values
- From: Kaitzschu
- Re: Inline return values
- References:
- Re: How to read the last 100 lines from a text file
- From: dave.joubert@xxxxxxxxxxxxxx
- Re: How to read the last 100 lines from a text file
- From: Kaitzschu
- Re: How to read the last 100 lines from a text file
- Prev by Date: Re: Tcl/Tk 8.5.3 RELEASED
- Next by Date: Extensive Tcl/Tk Library for Sale (21 volumes)
- Previous by thread: Re: How to read the last 100 lines from a text file
- Next by thread: Re: Inline return values
- Index(es):
Relevant Pages
|