Subject: Re: error codes and editMethods
Date: Mon Apr 24 2000 - 10:53:03 CDT
On Fri, Apr 21, 2000 at 01:19:36AM -0500, sam th wrote:
> I would like to be able to have some of the various functions found in
> ap_EditMethods.cpp be able to return error codes, instead of just
> true/false. Currently, they are all of the form
> static EV_EditMethod_Fn insertData;
> 1 - Abandon error codes for this purpose. This should be the last resort.
> 2 - Convert *all* the functions that use EV_EditMethod to returning error
> codes. *Lots* of work (but I would do it).
> 3 - Derive an additional class (or create a new one) for this purpose.
> 4 - Code some more flexibility into EV_EditMethod.
> Purely theoretically, I like option 4. However, I am not sure if it can
> be done/is a good idea. Unfortunately, the original developer (jeff) is
> no longer as active in AbiWord development. If someone has insight here,
> it would be appreciated.
the simple boolean interface was probably overkill at the time.
that is, the intended callers (keyboard/mouse/menu handlers) can't
do anything with the result -- it's already too late to know
what was going on. for example, if i type a letter 'e' into the
program and that gets routed to an 'insertData' or 'selfInsert'
function or a 'saveFile' function -- only that function knows the
significance of the problem and the appropriate action (dialog, log,
abort, etc). the keyboard handler really doesn't care whether the
keystroke succeded or not -- it's just routing key events. if a
key fails, the only thing it could do about it would be to stop
handling keys.... but that would be wrong.
i put in the bool return because of my tendency to generalize; it
could have been a void return just as easily. i think it was a
way of having macro expressions stop upon first error -- like emacs.
having said that, i'm curious who/what wants the extra info and
if inserting them here is correct thing to do??
it wouldn't be that hard to change the interface -- most everything
is macro-ified. but if you're wanting to use some of the code
currently inside an edit-method somewhere else in the program, you
might consider extracting the core functionality (and the error
return code) into a function and let the edit method call it and
do the E2B() trick and then do what you need to do with the core
i guess it would help if i knew what you wanted to do...
hope this helps,
This archive was generated by hypermail 2b25 : Mon Apr 24 2000 - 10:53:05 CDT