On Jan 16, 2008 8:01 PM, Christopher Smith <[EMAIL PROTECTED]> wrote:
> >> So, when a process can no longer log successfully, you'd rather keep
> >> it running than let it die, so it's parent can report the problem and
> >> spawn a new child?!?!
> > No. When logging throws an exception, the exception gets caught and
> > logged.
> /me just let's the logic of that sink right in. :-)

One might say: "When logging throws an exception, the exception gets
caught and logged in a different, more simple way."  I've used exactly
that technique in Python projects and it works. My fancer logger
choked and the primitive logger kicked in and succeeded.

Now maybe the primitive logger fails, but then nothing is perfect.

> It's not quite the same thing, but it can be a helpful tool for
> optimizing GC as well. My point is, all compilers fail to warn or
> enforce good conventions. It is the nature of the beast.

That's no longer true. Cobra warns and enforces various conventions
and will continue to do so.

Actually there are prior examples. Smalltalk requires that classes be
capitalized. C# gives an error (or maybe warning) if you invoke a
property as a statement (button.Color;). Many static languages warn or
give errors if you're missing a return statement in your code flow.

Maybe you just meant all compilers fail to enforce at least some good
conventions.

Regarding C#'s using statement:

* I've written lots of C# code and did not have to put "using" all
over the place.

* I found "using" pretty convenient when I needed it. And I can't
perceive C++'s crufty constructions and conventions as being any more
convenient than C#'s conventions.

* I did not find implementing IDisposable inconvenient. It's just an
interface with one method.

* You don't need extra checks beyond "using (...) { ..." because the
methods and constructors you invoke in "using(...)" either succeed (in
which case they need and get disposal) or fail via exception (in which
case there is nothing to dispose). Yes, you could write a class or
method that violates this. You could also write a method that divides
by zero every time. Or you could forget to wrap your C++ members in
auto_ptr's.

* C# doesn't have member initialization outside the code block; it
goes inside. If you're concerned that it will need cleanup, use
try...catch...finally like you would anytime you had such a concern:

    Foo() {
        try {
            a = ....;
            b = ....;
        } catch (Exception exc) {
            if (a!=null) { a.Dispose(); a = null; }
            if (b!=null) { b.Dispose(); b = null; }
            throw;
        }
    }

Not that this comes up that frequently... or hardly ever.


-Chuck

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to