Yukihiro Matsumoto wrote:

> Hi,
> 
> In message "[ruby-talk:26236] Re: [OT] Re: KDE or GNOME curiosity question..."
>     on 01/11/24, Edward Diener <eldiener / earthlink.net> writes:
> 
> |While GC is nice, every language which has it needs a mechanism which 
> |forces the immediate destruction of a particular type of object when 
> |that object goes out of scope. Why ? Because without this feature, it is 
> |impossible to design objects which have resources which must be 
> |immediately released when the object is destroyed ( RAAI ).
> 
> ??
> 
> Ruby and many other languages with GC (Java is in the same boat) allow
> resource finalization when the object is "destroyed".


I am aware of that but unfortunately, like Java, one can't force the 
object to be "destroyed" a well-ordered point. My belief is that you 
need a construct in your language which says that a certain type of 
object, to be used in RAAI situations, is destroyed when it goes out of 
scope. Perhaps this exists in Ruby and I have missed it, but if it 
doesn't I think you should think hard and long about incorporating it 
into the language. I know it doesn't exist in Java and nearly every Java 
programmer ( I am one myself ) with whom I discuss this shortcoming of 
the language, just accepts it and the workarounds needed to deal with it 
while being very aware of this hole in the language.

I know what the workaround is generally for these RAAI situations. It is 
to design a member function that essentially says that the object will 
no longer be used and therefore resources can be released when the 
member function is called. Then it is up to the user of that object to 
remember to call that member function when he is finished using that 
object. To say that I regard this as inelegant and a poor language 
design is an understatement.