Overuse of fatal runtime errors

new topic     » topic index » view thread      » older message » newer message

Regarding the discussion of short circuiting and sequence comparisons, I think
it's time I add my $.02...

Whether anybody agrees with the suggestions being posted, I believe most people
on this list would agree that a program *should not crash* with an expression
like ? "Hi" > "Lowest" !

Whether you want to return -1, 0, {-4,-6,0,0,0,0} or whatever doesn't matter to
me.  I can easily respond to whatever is returned as long as *something* is
returned.  Because Euphoria crashes on this kind of sequence comparison, for each
comparison of this sort, I need to surround the comparison by a number of if
statements just to allow for a single valid operation.

Granted, we have the compare function which is what I populate my code with now.
 We also have the equal function for those who constantly forget about =0. 
Personally, I don't mind using these functions and thus avoiding the birds nest
of safety checks.

However, the problem still remains:  there is *no* reason whatsoever for a
simple sequence comparison to crash.

I submit the following two suggestions (which are by no means original!):

1) Rather than crash on the comparison, pass the left and right values to the
compare function and return its result.

2) Add a keyword integer to the language that would be the routine_id of an
error-handling routine.  It could easily be implemented as follows:

// In ex.exe,

integer _iErrorCallback = -1;
boolean _bInErrorCallback = False;
...
// in internal error routine of ex.exe

if (!_bInErrorCallback && (_iErrorCallback > -1)) {
  _bInErrorCallback = True;
  runErrorRoutine (integer errNum, char* routine_name)
  // if the error occured in the error routine, then crash.
  // if there is no error routine, then crash.
  // if there is an error routine and the error occured elsewhere, run the 
  // error routine passing the error, and the name of the routine the error    
  // occured in.
}

-- In myprog.ex
procedure errorCallbackRoutine(object error, sequence routine)
  dostuff()
end procedure

errorCallback = routine_id("errorCallbackRoutine")
-- upon conclusion of the callback routine, control passes back to the line in
the program immediately following the line in which the error occured.

I apologize for such a long post, but I feel this feature has been a long time
lacking in the language and should have been implemented in version 2.0 alongside
routine_id.  Please, Rob, tell me how this would make Euphoria less safe for the
*end user* (they're the ones who really need the safety, aren't they?!?), less
simple for the programmer, and how would it break existing code!

Michael J. Sabal

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu