Re: Language design
Posted: Aug 28, 2006 4:31 AM
> For instance, I'm tempted to use a garbage collecter every
> so often, but I know that garbage collectors have
> drawbacks (mainly, you can't guarantee when an object will
> be collected, so you generally can't guarantee when the
> finalizer will be run, so you can't use the finalizer to
> run code that needs to be run at a specific point in
> time). The language has to give a strategy for memory
> management and resource management. Perhaps a language
> could (1) provide a garbage collector automatically, (2)
> make it possible to turn that collector off if you need
> to, and (3) provide facilities that make it possible to
> write (a) a different garbage collector, and (b) smart
> pointers, or other memry/rsource management techniques.
Resource management should not be coupled with garbage collection.
The time and place that a resource is used should have nothing to do with the way the owner of the resource is allocated.
D has a very good approach to it: objects marked as 'auto' are 'finalized' on function return (so RAII works for D), while the object is allocated on the heap.
While the above is irrelevant to the main discussion, I think It deserves to be clarified.