"with" should be deprecated with extreme prejudice
Christopher Wright
dhasenan at gmail.com
Mon May 18 15:26:54 PDT 2009
Andrei Alexandrescu wrote:
> Bill Baxter wrote:
>> On Mon, May 18, 2009 at 1:36 PM, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> wrote:
>>> That's not an "equiv of". It's "completely missing the point of". Each
>>> "using" costs one new scope and one level of indentation which makes it
>>> non-scalable. Indentation is *expensive*. I think the C# folks missed
>>> the
>>> class when try/catch/finally showed with extensive examples just how
>>> expensive extra indentation is.
>>
>> Oh. Is that the only thing that bothers you about it?
>> That doesn't bother me much since it's basically for things you only
>> want to hold on to for a short span. You should either do your
>> business in a few lines of code and get out of there, or if you can't
>> then make it a function. Anyway, if the indentation bugs you, you
>> can always set emacs up not to indent on "using" blocks.
>
> It's huge! In TDPL, as soon as I show the expansion of two scope(exit)
> statements, code became unreadable. No wonder today's software has so
> crappy error handling and state leaks: languages seem to make it as hard
> as possible to write correct transactional code.
>
> Andrei
Not to mention, C#'s implementation requires an object that implements
IDisposable. This means the code that actually executes is highly
non-local, and requires a fair bit of boilerplate. That makes 'using'
even less maintainable. (This is also my complaint about using RAII for
scope guards in C++.)
More information about the Digitalmars-d
mailing list