Re: A re-announce on GC's defects
- From: Andre Kaufmann <andre.kaufmann_re_move_@xxxxxxxxxxx>
- Date: Sat, 20 Jan 2007 08:15:47 +0100
Barry Kelly wrote:
Andre Kaufmann wrote:
[...]
Perhaps I've been programming C++ too long and can't get used to another programming style that easily ;-).
A C# developer coming from Delphi won't have such "problems".
Delphi Win32 users can also implement RAII, using interfaces.
Semantically this is comparable to C++ RAII. Though there are downsides using these interfaces, intentionally implemented to support COM, as a RAII replacement.
At function scope it's IMHO too much overkill, since the interfaced objects will be created on the native heap, instead being constructed on the stack as in C++. This would be a rather slow approach, for releasing resources at function scope commonly therefore try finally is used.
In .NET there isn't the same overhead as in Win32 in constructing objects. However a stack based approach would be IMHO faster, but C# has adopted the Delphi style and added the "using" keyword.
No big deal, though sometimes I'm missing RAII and assignment operator overloading or some approach of automatic resource handling.
If you ignore the runtime overhead for object construction in Delphi.W32, then I agree that you can use interfaces as a RAII replacement.
Interfaces
in Delphi are ref-counted COM-style interfaces, implemented behind the
scenes a lot like CComPtr<T> and friends.
Yes, but IMHO the internal implementation of interfaces is hidden too much. They are perfect if you don't mix them with other objects, e.g. hold them in the same object list. Otherwise I'll promise a developer doing this having much fun ;-).
-- Barry
Andre
.
- References:
- A re-announce on GC's defects
- From: Born
- Re: A re-announce on GC's defects
- From: Andre Kaufmann
- Re: A re-announce on GC's defects
- From: Barry Kelly
- Re: A re-announce on GC's defects
- From: Andre Kaufmann
- Re: A re-announce on GC's defects
- From: Barry Kelly
- A re-announce on GC's defects
- Prev by Date: Re: Protecting classes
- Next by Date: Re: Fun with printers
- Previous by thread: Re: A re-announce on GC's defects
- Next by thread: Re: A re-announce on GC's defects
- Index(es):
Relevant Pages
|