cool beans, thanks.  wow, perl is neat, but i fear it will make me a bad c 
programmer...;)

so i guess there is no concept of stack and heap space when dealing with perl?  
just that memory will stay allocated as long as there is a way to reach it?  
hehe, i can't wait to abuse that fact....;)

christopher

On Tuesday 17 December 2002 12:21 am, John W. Krahn wrote:
> Christopher J Bottaro wrote:
> > hmm, something is going off in my head that says this is scary.
>
> Calm down Christopher.  :-)
>
> > @array is
> > local to the function (lexically scoped as you would say in perl??) and
> > you are returning a reference to it.
>
> Yes, that is correct.
>
> > well when the function goes out of scope,
> > isn't @array deallocated (popped off the stack) and now that reference
> > you returned is pointing to garbage?
>
> No, as long as there is still a reference to the array the data is
> available.
>
> > or is perl's garbage collection sophisticated enough to realize the
> > difference between:
> > myfunc();
> > and
> > my $ref = myfunc();
> > and not deallocate @array in the second example?
>
> Yes, that is correct.
>
> > also, i do understand that [ @array ] constructs and anonymous array,
> > copies @array into it, then returns a reference to to the new anonymous
> > array.  as opposed to \@array which merely returns a reference to
> > something that already exists.
>
> Yes, that is correct.
>
> > but i guess my questions is...well, i asked it above...about whether
> > or not @array will still be in existance when the function ends...
>
> If you assign the reference to a scalar, then yes.
>
>
>
> John
> --
> use Perl;
> program
> fulfillment


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

Reply via email to