--- arcadi shehter <[EMAIL PROTECTED]> wrote:
> Larry Wall writes:
> >
> > Er, how would LEAVE detect that this was the *last* time you're
> > ever going to call this routine?
> >
> > On the other hand, if we renamed FIRST and LAST to ENTER and
> > LEAVE, then FIRST would become available
Larry Wall writes:
>
> Er, how would LEAVE detect that this was the *last* time you're ever
> going to call this routine?
>
> On the other hand, if we renamed FIRST and LAST to ENTER and LEAVE,
> then FIRST would become available to mean "my very first time"...
>
and LAST will mean "just
suppose I want this behaviour :
sub new_counter($start=0) {
my $cnt = $start;
my sub incr {
++$cnt;
};
my sub decr {
--$cnt;
};
return sub (str $how="incr")
{
give
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
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
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!
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
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
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"
: >
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
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
--- 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
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
Matthijs van Duin writes:
>
> >does it mean that this is legitimate
> >
> > sub a {
> > state $x;
> > my $y;
> > state sub b { state $z ; return $x++ + $y++ + $z++ ; }
> > return &b; # is a \ before &b needed?
> > }
>
> No, since you can't refer to $y in that s
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 to the same $z ?
yes, they will
does it mean that this is legitimate
su
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 same
On Sat, Mar 22, 2003 at 09:45:43PM +0200, arcadi shehter wrote:
in this example
sub a {
state $x ;
my $y ;
my sub b { ... } ;
...
}
how "my sub b" is different from "state $x" from the point of view of
scope ?
Actually, all three have the same scope, but they have different lifet
Larry Wall writes:
>
> I think it's also a mistake to give C two unrelated meanings.
> These are not lexically-scoped variables any more than "our"
> variables are, and the fact that they can happen accidentally in
> Perl 5 as persistent lexically scoped variables is, er, accidental.
> They
18 matches
Mail list logo