From: [EMAIL PROTECTED]
> ------------------------------------------------
> On Thu, 19 Dec 2002 11:04:27 -0500, [EMAIL PROTECTED]
> wrote:
> > But is it not wrong to create an array in a function and send a
> > reference to the array back into the main function?
> > 
> > Because the scope of the array is limited to the function and
> > calling a reference that is not available(the variables local in
> > scope to the function are collapsed) must be illegal!!
> > 
> > Regards,
> > Satya
> 
> You have just learned what a closure is :-).  At least that is my
> understanding of one.  

No this is not a closure.

This is:
        sub createClosure {
                my $x = shift;
                return sub { print $x++,"\n" }
        }

        $closure = createClosure( 5 );
        $closure->();
        $closure->();

Closure is a function that references a variable lexical to the scope 
it was created in even though the scope is long gone.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


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

Reply via email to