As was mentioned earlier, a closure can as well be a named sub, not
necessarily an anonymous.
Ilya
-Original Message-
From: Paul Johnson
To: Dave Mitchell
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: 08/21/2001 11:39 AM
Subject: Re: explicitly declare closures???
On Tue, Aug 21, 2001
On Wed, Aug 22, 2001 at 10:34:49AM +0100, Dave Mitchell wrote:
> Paul Johnson <[EMAIL PROTECTED]> wrote:
> > Actually, foo() is not a closure. A closure is an anonymous subroutine
> > and foo() clearly has a name.
>
> Damain's definition of a closure includes named subs:
>
> "In Perl, a closure
On Tue, Aug 21, 2001 at 06:06:06PM +0100, Dave Mitchell wrote:
> Piers Cawley <[EMAIL PROTECTED]> wrote:
> > > {
> > > my $x = "bar";
> > > sub foo {
> > > # $x # <- uncommenting this line changes the outcome
> > > return sub {$x};
> > > }
> > > }
> > > print foo()->();
> >
> > W
John Porter <[EMAIL PROTECTED]> wrote:
> Dave Mitchell wrote:
> > I think closures are a lot harder (or at least subtler) than people
> > think,
>
> It's hard for me to agree with you, because I've never had *any*
> problems with closures. (And yes, I use them all the time.)
> The scenario you g
Dave Mitchell wrote:
> I think closures are a lot harder (or at least subtler) than people
> think,
It's hard for me to agree with you, because I've never had *any*
problems with closures. (And yes, I use them all the time.)
The scenario you gave seems rather far-fetched to me, in terms
of real-
> "Dave" == Dave Mitchell <[EMAIL PROTECTED]> writes:
Dave> Paul Johnson <[EMAIL PROTECTED]> wrote:
>> Actually, foo() is not a closure. A closure is an anonymous subroutine
>> and foo() clearly has a name.
Dave> Damain's definition of a closure includes named subs:
Dave> "In Perl, a closu
Paul Johnson <[EMAIL PROTECTED]> wrote:
> Try changing your original example from
>
> sub foo {
>
> to
>
> *foo = sub {
>
> and you'll see that everything works "as expected".
add a BEGIN so that instantion happens at the same time that a named
sub would be:
BEGIN { * foo = sub { } }
> I guess you missed where I suggested that putting "my" on that
> declaration is also counter-sensical, not to mention redundant.
> "my" implies a brand-spanking-new lexical variable attached
> to this very scope. The semantics of "outer" (or "closed"...)
> can be defined to imply a lexical var
Paul Johnson <[EMAIL PROTECTED]> wrote:
> Actually, foo() is not a closure. A closure is an anonymous subroutine
> and foo() clearly has a name.
Damain's definition of a closure includes named subs:
"In Perl, a closure is just a subroutine that refers to one or more lexical
variables declared o