Re: lambda... again
- From: Neil Madden <nem@xxxxxxxxxxxxx>
- Date: Tue, 23 Oct 2007 19:12:08 +0100
slebetman@xxxxxxxxx wrote:
....
OTOH since variables are locally scoped writing tcl code in pure
lambdas is going to be annoying:
set something {{} {
global do_something print ;# must "import" all lambdas before
using :-(
$do_something here
$print Done!
}}
set do_something {{x} {
global print ;# typing global all the time quickly gets annoying
$print "doing something: $x"
}}
set print {x {puts "$x\n"}}
$something
You don't have to store lambdas in variables, you can also [interp alias] them:
interp alias {} do_something {} apply {{..} {...}}
Although, of course, if you are doing this then it is best to just use a regular named procedure. The most likely use of a lambda is when it is passed either to or from a procedure as an argument/return value, so no importing would be needed.
-- Neil
.
- Follow-Ups:
- Re: lambda... again
- From: Yuriy Ershov
- Re: lambda... again
- References:
- lambda... again
- From: yuriy . ershov
- Re: lambda... again
- From: slebetman@xxxxxxxxx
- Re: lambda... again
- From: suchenwi
- Re: lambda... again
- From: slebetman@xxxxxxxxx
- lambda... again
- Prev by Date: Re: Call by Reference
- Next by Date: Re: OT - people v computer
- Previous by thread: Re: lambda... again
- Next by thread: Re: lambda... again
- Index(es):