Python vs Java garbage collection?
Antonio Cuni
cuniREMOVE_THIS at programmazione.it
Sat Dec 28 07:27:42 EST 2002
Stuart D. Gathman wrote:
>> def foo():
>> auto mymutex = acquire_mutex()
>> auto myfile = open(filename, 'w')
>> auto mysocket = open_socket()
>> do_stuff
>>
> 1) This feature should not reclaim memory, only call __del__(). If
> references were still live, the effect would be the same as calling
> __del__() on a live object.
>
> 2) __del__() would get called again when memory is actually reclaimed.
> Therefore, your feature would be much safer if it called another
> special function - say close() or dispose() at the end of the block.
I can think to something totally different: for example an "auto" object
couldn't be used as an r-value; such a check could be partially done a
compile-time.
But what to do with parameter to function? There should be a way to
assure that a function doesn't store anywhere an "auto" object passed as
a parameter; e.g. we could disallow parameter-passing unless the
function declares its arguments "auto".
But these are only my thoughts: perhaps they are completly wrong... ;-)
> 3) There is probably a way to do what you want without additional
> syntax:
>
> def foo():
> mymutex = auto(acquire_mutex())
> myfile = auto(open(filename,'w')
> mysocket = auto(open_socket())
> do_stuff()
I can't think of any way to do what I want using this syntax: what are
you thinking of?
ciao Anto
--
"Computer science is not about computers any more than astronomy
is about telescopes." -- EW Dijkstra
More information about the Python-list
mailing list