in reply to Re^6: No garbage collection for my-variables
in thread No garbage collection for my-variables

Wouldn't it be great if we could actually fix the problems in the compiler, instead of work around them?

That presumes that this is a problem in the compiler. And I for one, don't think it is. It is a problem with education and attitudes.

For the vast majority of Perl applications, this compiler optimisation is a positive boon. Any application that calls subroutines and methods more than once benefits from this optimisation. And the more times you call those routines, the more you benefit.

The OP outlined a very specific scenario in which this can be perceived as a problem. His example: I've named the subroutine "init" to suggest that this is code that will only be used at the very start of a long program lifetime, which means that the long string buffer will linger around needlessly..

For the vast majority of situations, passing scalars by reference simply isn't necessary or beneficial. But for that small set of cases when you are passing a large volume of data to a used once (or few times) subroutine, then Perl has the facilities to handle that. If people would just use them.

It doesn't make sense to throw away the benefits in the general case, for the sake of avoiding a mildly advanced but perfectly understandable and usable technique, for the degenerate case. Especially not for the sake of a little read-it-once-and-understand-it, education. And certainly not for the sake of some CS dogma.

Relax.

I'm perfectly relaxed thank you. This isn't emotional frustration I'm expressing. It's intellectual frustration.

The same sort you feel when you see some politician, when asked; "Why have you cocked up the economy?", respond with: "First let me say that since I/we came to power there is far less dog poo in our parks and 100,000 more police officers handing out ASBOs and nicking people for seat belt violations...". And never actually answering the question asked.

It would be far better to 'fix' the modules that create the problem, for that tiny subset of all Perl code that are memory constrained, than to penalise the performance of every non-memory constrained Perl app in order to avoid the use of pass-by-reference or aliasing.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."
  • Comment on Re^7: No garbage collection for my-variables