Re: Contracted exceptions for Ada

"Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx> writes:

No problem. Exception contracts should be inheritable. File open would say
"I raise this and that and also anything disk driver does." (I remember
Robert Duff proposed that once.)

I think what I proposed was more like what you say below:

what about
call-back routines (think Process in the Containers library); and so on.

Conditional contracts: container's Forall is exception E free if Process

Right -- an iterator needs to be able to say "I can raise anything
raised by the loop-body procedure that is passed in to me."
That's one thing missing from Java, which makes exception
contracts more painful than they need to be. Passing a procedure to an
iterator causes the compiler to lose useful information.

I think preconditions could help a lot in this general area -- instead
of saying "I might raise Divide_By_Zero" on the divide procedure, one
can specify exactly what circumstances cause that exception --
Divide_By_Zero will be raised if and only if you try to divide by zero.
Then if at the call site, you divide by X, and X is Positive, there's
no need for a handler. Unfortunately, there's no Non_Zero subtype.

- Bob

Relevant Pages

  • Re: Exceptions and out procedure arguments (using GNAT GPL)
    ... raise My_Exception; ... and has an exception handler ... you can count on any assignments that you've already done ... The sample is a highly condensed version of my Query procedure ...
  • Re: contracted exceptions
    ... silently dies -- without notifying anyone. ... Enforcing the subprograms ... superior to the existing rule of silently ignoring the exception. ... Or raise Program_Error in the parent task at the point where that task ...
  • Re: ascii to tword - help
    ... if(cmp128(inputL, ... Raise($1_1285); ... we succeeded if we got this exception. ...
  • Re: AssignFile, Reset und IOResult 103
    ... on exception do ... Raise ESecHashException.Create('File not found! ... Raise ESecHashException.CreateFmt('Could not open File ''%s''.'#13#13' ... Die beiden Dateinamen haben definitiv nichts miteinander zu tun. ...
  • Re: assert expressions
    ...  And where are you placing this assert? ... unconditionally raise an exception. ... helpflag = False ...