gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnu-arch-users] Nit


From: Dustin Sallings
Subject: Re: [Gnu-arch-users] Nit
Date: Mon, 20 Oct 2003 13:39:03 -0700


On Monday, Oct 20, 2003, at 11:57 US/Pacific, Andrew Suffield wrote:

        In languages that do not raise exceptions normally upon error, you
have to check the results of each of those calls to make sure they're
successful, as well as figuring out something to do when they're not.
These are two things that put extra burden on a programmer that is
often skipped because it's additional work that is not directly related
to the logic that the programmer wants expressed.

I have never written code like this. Anybody who does is a
moron. Morons cannot be helped except with a shotgun, and should
definitely not be allowed to write code.

Unless you've only programmed in languages like Eiffel (where exceptions are always present and return values cannot be ignored), I don't think I can believe you when you say that you've never ignored the return value of a function that could have indicated an error of some sort (printf, etc...).

Fatal for now, I think that's a fairly stupid hack) in order to remove
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

That says it all, really. It does precisely what you want with no
appreciable source code or runtime overhead, while making the other
path available to people that want it with similar lack of overhead,
and you call it a "stupid hack".

I think your value function is broken, or at least contrived.

It does not do precisely what I want. I want to code for the One True Path and have it be executed fully when all operations succeed. I will optionally add handling for specific error conditions if I feel there's an appropriate way to handle them, but I will know that the application will, by default, stop when the first thing I told it to do cannot be done.

Fatal gives you the option to basically interposition a wrapper around a function so it can throw an exception if the result of the underlying returns a value that would be evaluated as false. It does this specifically for each function you request.

        This is a stupid hack for the following reasons:

1) It can't be applied in general (you have to specifically list every function you'll ever want to throw an exception).

2) Because of #1, the process is inconsistent, therefore unreliable (you miss one, and your application will mysteriously fail).

3) If 0 or undef is a valid result for a function, it can't be wrapped with Fatal.

4) If 0 or undef is not an invalid result for a function, it also can't be wrapped with Fatal (this is different from #3 in that a function may return -1 to indicate failure).

5) If 0 is a valid, but undef is an invalid result from a function, Fatal cannot be used.

It's a bad hack. I apologize if you wrote it...or whatever makes you care for it so much, but an inconsistency or inaccuracy in error handling methodology is worse than one that puts a greater burden on the programmer.

--
Dustin Sallings





reply via email to

[Prev in Thread] Current Thread [Next in Thread]