What language was the first to implement exception handling?

前端 未结 9 2080
不知归路
不知归路 2021-01-01 16:13

This question is not a technical but a historical one. I was just thinking today that I\'ve also thought of Java as the \"first\" language to use exception handling, until I

9条回答
  •  孤城傲影
    2021-01-01 16:37

    Algol 68's "transput" had "event" handling, but it wasn't streamline enough for the programmer to extent it.

    The ALGOL 68 standard uses event routines extensively in the "standard transput" (stdio) to manage the various events that arise when data is read (or written) to a file or external device. The built in "on event" routines are:

    • on char error, on format error, on line end, on logical file end, on page end, on physical file end & on value error

    In 1983 Proposals were being accepted to allowing a programmer defined their own exceptions. AFAIK none of these proposals were accepted by the United Nation's IFIP.

    However the Russians standards body "GOST" did standardize exception handling near the end of Glasnost/Гласност in the standard "GOST 27975-88 Programming language ALGOL 68 extended - Язык программирования АЛГОЛ 68 расширенный"

    GOST 27975-88 used the additional keywords: MODULE, PUB, POSTLUDE, NEST, EGG, ON, EXCEPTION and RAISE.

    Here are the original UK proposals:

    1. AB49.1983-May : "A Proposal for Exception Handling in ALGOL 68", by C. H. Lindsey - Pages: 10 - 15

    2. AB49.1983-May : "An Exception-Handling Mechanism for ALGOL 68", by Martyn Thomas - Pages: 16 - 17

    They appear similar to what is now implemented in python.

    Lindsey's Example:

        EXCEPTION singular = new exception ; # EXCEPTION la a new mode #
        PROC gauss = ( REF [ , ] REAL a. REF [ ] REAL rhs ) VOID :
              COMMENT a procedure to solve a set of simultaneous
                          equations COMMENT
              BEGIN C the usual algorithm for gaussian elimination which, at some
                                  point, may discover that a is singular C ;
                       IF C it makes this discovery C
                       THEN RAISE singular
                       FI;
                       C rest of algorithm CO
              END;
    

    Exceptions bulitin were: time exhausted, space exhausted, arithmetic error, bounds error, scope error, transput impossible, file end, char error, value error and format error

    Martyn Thomas's Example:

        BEGIN
          on ( overflow , overflow handler ) ;
          on ( bound check, boundcheckhandler ) ;
          C body of the closed - clause C
        EXIT
        overflow handler:
                C handle overflow exceptions C
        EXIT
        bound check handler:
            C handle bound check C
        END
    

    BTW: The Soviet's Space Shuttle Buran/Буран completed one unmanned spaceflight in 1988, the automatic landing system was written in Algol. The Amercian's still deploy numerous bits of military/space apparatus in Jovial (Algol 58), and this may contain exception handling from the 1950s. Anyone got any ideas on this?...

    Wikipedia: Buran_(spacecraft): The shuttle orbited the Earth twice in 206 minutes of flight. It performed an automated landing on the shuttle runway at Baikonur Cosmodrome where, despite a lateral wind speed of 61.2 kilometres (38.0 mi) /hour, it landed only 3 metres (9.8 ft) laterally and 10 metres (33 ft) longitudinally from the target.

提交回复
热议问题