[PEP] auto keyword for automatic objects support in Python

Manlio Perillo NOmanlio_perilloSPAM at libero.it
Wed Jun 23 09:56:32 EDT 2004


On Tue, 22 Jun 2004 12:16:05 +0300, Christos "TZOTZIOY" Georgiou
<tzot at sil-tec.gr> wrote:

>On Fri, 18 Jun 2004 16:32:39 GMT, rumours say that Manlio Perillo
><NOmanlio_perilloSPAM at libero.it> might have written:
>
>[snip]
>
>
>[snip]
>
>I'm afraid your PEP's strongest adversary will be the "Explicit is
>better than implicit".  You suggest complications to the language
>implementation that can be avoided just by user code.
>
>For example, you could have a class Deallocator (untested improvised
>code):
>
>class Deallocator:
>    def __init__(self, *args):
>        self.args = args
>    def deallocate(self):
>        for obj in self.args:
>            obj.__deinit__()
>
>then in your function start:
>    auto = Deallocator(obj1, obj2 ...)
>
>and in your function end:
>    auto.deallocate()
>
>If your function has multiple exit points, wrap its code in a try ...
>finally sequence.
>
>

The problem is that one have to use finally consistently.
The C++ RAII pattern is more simple.


Thanks and regards  Manlio Perillo



More information about the Python-list mailing list