In article <[EMAIL PROTECTED]>, Rob Dixon wrote:

> Kevin Pfeiffer wrote:
>>
>> I would have thought that this would initialize my $indent variable to 2
>> (like setting an initial state for an object), but if I call "indent()" I
>> get nothing back. :-(
>>
>>
>> {  # static local variable
>>    my $indent = 2;
>>
>>    sub indent {
>>       my $increment = shift;
>>       $indent += $increment if $increment;
>>       return $indent;
>>    }
>> }
> 
> By the way, that's not a closure! It's just a subroutine
> with a non-volatile local variable.

Hmmm, does the subroutine need to to only exist as a reference to an
anonymous subroutine to be a closure? I'm going by what I read in Learning
Perl Objects, but I may be misinterpreting what I _thought_ I read.

-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to