By ace77
via informit.com
Published: Mar 19 2007 / 01:13
![]() | |
| HTML5 Canvas | |
| Written by: Simon Sarris | |
| Featured Refcardz: Top Refcardz: | |
| 150+ Refcardz Available · Get them all | |
By ace77
via informit.com
Published: Mar 19 2007 / 01:13
Comments
Ricky Clarkson replied ago:
Heap is not automatically returned when a local variable referring to it is destroyed. It is just possible for it to be returned. The author talks about making things private for security, completely neglecting to mention that you can access private fields via reflection, unless you install a suitable security manager. Private isn't usually for security, but for simplicity and to allow code to evolve at a different speed to its clients.
As an aside, it's also not necessarily the best way, e.g.:
(let ((x 0))
(lambda () (incf x 1)))
Every time you run that code you get a new counter function that updates its own copy of x, but x isn't part of the function object. Java supports that via inner classes, but for locals, only for finals.
Voters For This Link (8)
Voters Against This Link (0)