Re: grab-bag questions

2003-03-24 Thread Piers Cawley
David Storrs <[EMAIL PROTECTED]> writes: > Piers, > > Apologies...I actually put them into one mail deliberately, because I > didn't want to burn more mindspace than necessary...people could skim > all my questions at once, answer those they were interested in, and be > done. I didn't think about

Re: is static? -- Question

2003-03-24 Thread Dan Sugalski
At 10:34 AM -0800 3/24/03, Larry Wall wrote: On Mon, Mar 24, 2003 at 12:05:13PM -0600, Jonathan Scott Duff wrote: : On Mon, Mar 24, 2003 at 09:34:23AM -0800, Larry Wall wrote: : > The purpose of a state variable is to keep state across multiple calls : > to the same scope, so I'd say the proper sem

Re: is static? -- Question

2003-03-24 Thread Larry Wall
On Mon, Mar 24, 2003 at 12:05:13PM -0600, Jonathan Scott Duff wrote: : On Mon, Mar 24, 2003 at 09:34:23AM -0800, Larry Wall wrote: : > The purpose of a state variable is to keep state across multiple calls : > to the same scope, so I'd say the proper semantics on closures is : > to treat the genera

Re: is static? -- Question

2003-03-24 Thread Matthijs van Duin
On Mon, Mar 24, 2003 at 01:37:01PM -0500, Dan Sugalski wrote: Since I'd as soon not encourage this, how about INSTANTIATE? Nice and long and therefore discouraging. :) Nothing a macro can't fix :-D -- Matthijs van Duin -- May the Forth be with you!

Re: is static? -- Question

2003-03-24 Thread Dan Sugalski
At 12:05 PM -0600 3/24/03, Jonathan Scott Duff wrote: On Mon, Mar 24, 2003 at 09:34:23AM -0800, Larry Wall wrote: The purpose of a state variable is to keep state across multiple calls to the same scope, so I'd say the proper semantics on closures is to treat the generation of a closure as a new

Re: is static? -- Question

2003-03-24 Thread Jonathan Scott Duff
On Mon, Mar 24, 2003 at 09:34:23AM -0800, Larry Wall wrote: > The purpose of a state variable is to keep state across multiple calls > to the same scope, so I'd say the proper semantics on closures is > to treat the generation of a closure as a new block with new state properties. > The most useful

Re: is static? -- Question

2003-03-24 Thread Larry Wall
On Mon, Mar 24, 2003 at 06:29:10AM -0800, Austin Hastings wrote: : : --- arcadi shehter <[EMAIL PROTECTED]> wrote: : > is there any chance for this to work : : > : > sub new_counter($start=0) { : > return sub { : > prop $cnt = $start; #this is opposite to "state" : >

grab-bag questions (was Re: A6 questions)

2003-03-24 Thread David Storrs
Piers, Apologies...I actually put them into one mail deliberately, because I didn't want to burn more mindspace than necessary...people could skim all my questions at once, answer those they were interested in, and be done. I didn't think about how this would impact the summaries. In future, I'll

Re: is static? -- Question

2003-03-24 Thread Matthijs van Duin
On Mon, Mar 24, 2003 at 03:23:21PM +, Piers Cawley wrote: Are you sure about that. If state is declaring a lexically scoped alias to a property of the block/sub, then each invocation of a will generate a different block/sub &b, which implies that the various &b instances won't share the same $z

Re: A6 questions

2003-03-24 Thread Piers Cawley
David Storrs <[EMAIL PROTECTED]> writes: > Greetings all, > > Ok, it took me several days to get through A6, and I'm not caught up > on all the mail yet (though I've tried to skim so I don't repeat > someone else's question). I'm left with a bunch of questions; can > anyone answer the following:

Re: is static? -- Question

2003-03-24 Thread Piers Cawley
Matthijs van Duin <[EMAIL PROTECTED]> writes: > On Sat, Mar 22, 2003 at 10:24:09PM +0200, arcadi shehter wrote: >> sub a { >> state $x; >> my $y; >> my sub b { state $z ; return $x++ + $y++ + $z++ ; } >> return &b; # is a \ before &b needed? >> } >> >> >>will all &b refer t

Re: is static? -- Question

2003-03-24 Thread Austin Hastings
--- arcadi shehter <[EMAIL PROTECTED]> wrote: > Matthijs van Duin writes: > > > > A nice example is: > > > > sub a { > > state $x; > > my $y; > > my sub b { return $x++ + $y++; } > > return &b; # is a \ before &b needed? > > } > > > > Every call to sub a will return

Re: is static? -- Question

2003-03-24 Thread arcadi shehter
Matthijs van Duin writes: > > A nice example is: > > sub a { > state $x; > my $y; > my sub b { return $x++ + $y++; } > return &b; # is a \ before &b needed? > } > > Every call to sub a will return a different closure. The $x in each closure > all > refer to the sa