COBOL and exceptions (was: Passing an invalid date to INTEGER-OF-DATE



There was a lot of discussion as to whether or not the '89 Amendment should have
been passed with no method for detecting argument errors. The first draft DID
include returned-values to indicate "problems" - but as some functions could
have invalid arguments but NO returned value was always "invalid" this was
(eventually) rejected.

The '02 Standard (as Chuck indicates) did introduce a "Common Exception
Handling" facility that was intended to provide a "common" solution to ALL of
the exceptions mechanisms previously available - as well as for some things
(like "incompatible data" and invalid arguments) for which NO mechanism
previously existed.

The most controversial part of this proposal (now standard) was whether
detection should be "inline" (IF right after the exception) or out-of-line
(declaratives). The Standard went with the latter *and* provided a "RESUME"
statement that let you restart at a few "selectable" places. This requires
"totally UN-structured" code and is still (at least a little) controversial.

HOWEVER, and this is a BAGGIE !!!!
I know of NO vendor who has actually implemented the '02 Standard "common
exception handling" specification (much less implemented it completely). I have
heard (unofficially) from some vendors that they have ZERO intention of ever
doing so - even if they did everything else in the '02 Standard. At least one
vendor has adopted a C-like "throw/catch" (or whatever C uses) facility.

The good news (related to the initial thread) is that the '02 Standard also
introduced some TEST-xxxx intrinsic functions that allow a programmer to
"validate" arguments for a number of other intrinsic functions and to determine
why they are invalid (if they are). I don't know which vendors (if any) have
implemented these, but I have heard more positive feedback about them - than for
the entire "common exception handling" model.

P.S. For those used to other environments, the Common Exception Handling
facility is similar (not identical to) the PL/I "ON-unit" facility and/or the
(IBM CICS) EXEC CICS HANDLE CONDITION facility.

--
Bill Klein
wmklein <at> ix.netcom.com
"Chuck Stevens" <charles.stevens@xxxxxxxxxx> wrote in message
news:d700q2$b7s$1@xxxxxxxxxxxxxxxxxxxxxxx
> I'm not convinced ON ERROR is necessarily the best approach here, or for
> that matter in general, particularly given the ability to "nest" function
> calls.
>
> The '02 standard includes exception handling (for this and in general) in a
> way that, in my opinion, doesn't invalidate existing programs and allows
> their enhancement to catch such problems. Lobby your vendors!
>
> -Chuck Stevens
>
> "Howard Brazee" <howard@xxxxxxxxxx> wrote in message
> news:d6vutt$3fp$1@xxxxxxxxxxxxxxxxxxxxxxx
>>
>> On 24-May-2005, "Chuck Stevens" <charles.stevens@xxxxxxxxxx> wrote:
>>
>> > Note that Unisys MCP COBOL85 gives a zero response to an INTEGER-OF-DATE
>> > call in which any part of the argument is incorrect -- for example,
> 20050532
>> > and 20051324 will both return zero.
>>
>> IMHO, the biggest weakness in the CoBOL language is that it was not
> designed for
>> easy standard error handling. This particular solution is easy, but
> doesn't
>> work for all function calls. ON ERROR would have been a better
> design - as
>> a standard.
>
>


.



Relevant Pages

  • Re: exception handling for intrinsic functions
    ... past experiences) my GUESS is that IBM would implement COBOL features first ... I think that the VSE COBOL ... > implement the 2002 COBOL standard. ... > the benefit of the Intrinsic Functions. ...
    (comp.lang.cobol)
  • Re: Instr()
    ... F90/95 and F2003 have very similar sections differing only in inclusions for newer language elements and editing. ... IF there were a Standard for VB it would contain definitions quite similar although not identical because of syntax and implementation differences. ... A subprogram is a program unit that has a FUNCTION, SUBROUTINE, or BLOCK DATA statement as its first statement. ... Subroutines, external functions, statement functions, and the intrinsic functions are called procedures. ...
    (microsoft.public.vb.general.discussion)
  • Re: Trap rvalues
    ... I'm not debating that the standard is being sloppy. ... standard actually means both valid and "invalid" values when it talks ... returning invalid values results in undefined behavior, ...
    (comp.std.c)
  • Re: Trap rvalues
    ... The standard says functions return values; ... the standard never defines "valid value" or "invalid value", ... a trap representation doesn't represent a value. ... Except for the case of a pointer value that goes bad while being returned ...
    (comp.std.c)
  • Re: printf("%p ", (void *)0);
    ... > enough for the standard to be clear to people who already know the ... also possible to understand the intent in most cases by ... practice, explanatory, not a definition, as is quite ... explanation about what is meant by "an invalid value", ...
    (comp.lang.c)