From: yitzle <[EMAIL PROTECTED]> > IIRC, the stack pointer is part of the operating system, not the C language. > When a subroutine is called, the parameters are pushed to the stack, > and the return value is stored in a specific register.
Well ... depends. If you want to call a function provided by the OS you have to do what the OS expects. You have to put the parameters that function expects in the expected format at the expected place. OTOH, how do you internaly call functions is really up to you and the OS doesn't play any part in that. > When a routine creates a variable, the system's memory allocator finds > a new piece of unused memory to use. Not necessarily true. Most likely the process's internal memory allocator finds a new piece of unused memory and only if it can't find any asks the OS's memory allocator for some more. And it asks for a big block, not just for a piece that you need at the moment. > If you call a routine (or function) that creates a variable, when the > routine returns, the memory is marked free, but the OS does not clean > the memory, so the contents can still be accessed, until the OS reuses > that memory. 1) "my" variables have a BLOCK scope, not a subroutine scope. The memory is marked free (returned to the process's memory allocator) whenever you loose the last reference to it. Which may be because a variable ran out of scope (that is the block in which it was declared ended) or because you undefed or changed the value of the last variable that held a reference to the value stored there. Whether that memory is cleared or not is undefined and irrelevant as there is no way to access it. (well, unless you are really cheeky, did keep a stringified address and use something that allows you to peek under the hood. Don't do that!) > What are you trying to do? Access that memory? Why? Are you trying to > return a reference from a subroutine and access what is referenced? > You can do that. As long as memory is referenced, Perl does not > release it. You are right in that one. 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] http://learn.perl.org/