in reply to Re^3: No garbage collection for my-variables
in thread No garbage collection for my-variables
Thanks to perl's context sensitivity, you can have the best of both worlds. For the simple case, subroutines behave as passthru pass-by-value, but when the need arises to minimise memory allocation and copying, using it ina void context does the right thing
Now that's surely tempting, but could lead to rather odd situations:
sub do_stuff { ... do_other_stuff($variable); # remove that debugging statement, and do_other_stuff # will behave very differently if do_stuff is not # called in void context print "still here\n"; }
Admittedly that's a fairly artificial situation and won't show up in real code very often, but if it does it's very nasty to debug.
Designing interfaces around performance optimizations and memory management oddities just doesn't seem right to me.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: No garbage collection for my-variables
by BrowserUk (Patriarch) on Sep 17, 2008 at 00:06 UTC | |
by moritz (Cardinal) on Sep 17, 2008 at 07:19 UTC | |
by BrowserUk (Patriarch) on Sep 17, 2008 at 08:28 UTC | |
by kyle (Abbot) on Sep 17, 2008 at 03:19 UTC | |
by BrowserUk (Patriarch) on Sep 17, 2008 at 05:53 UTC | |
by kyle (Abbot) on Sep 17, 2008 at 15:08 UTC | |
by BrowserUk (Patriarch) on Sep 17, 2008 at 15:28 UTC |