• Re: Algol68 / Genie - ASSERT isn't NIL, but "access NIL" runtime error?

    From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.misc on Mon Sep 29 23:16:15 2025
    From Newsgroup: comp.lang.misc

    On 29.09.2025 22:54, Richard Tobin wrote:
    In article <10bbp43$2fsef$1@dont-email.me>,
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

    I basically agree with that. But, that said, I'm obviously not used
    to these castings and the user-defined type-specific NIL definitions.
    My intention here was to get a better feeling for this approach.

    If I inspect my Algol 68 textbook from the 1970's I also cannot find
    a single use of such a code pattern. - Concerning my use of Algol 68
    I'm very biased by its contents, and by the university teaching I
    got. - There was just a single context type for such REF casts, and
    no "own" 'nil' ever required.

    The ALGOL 68-R Users Guide gives an example of a linked list type:

    MODE LINK = STRUCT(INT item, REF LINK next);

    This is the trivial part. (You find it "everywhere".)


    It recommends declaring a null reference for the end of the list:

    REF LINK empty = NIL;

    This is what Andy also suggested.


    The reason why this is preferable is that it enables us to test for the
    end of the chain by means of the clause

    next OF d IS empty

    This is where the language references or textbooks I used typically
    write code with an explicit coercion like

    REF LINK (next OF d) IS NIL

    (or similar); which is another option to introducing "empty". - The
    advantage of the type-specific "nil" (like your "empty") is that it
    avoids writing these coercions throughout the program.


    The mode of 'empty' causes 'next OF d' to be dereferenced to REF LINK

    There's a copy of the guide at

    https://github.com/coolbikerdad/Algol-68-Publications/blob/main/Algol68-R%20Users%20Guide.pdf

    Thanks. - I think this issue is understood. Andy also elaborated on
    that already. :-)

    Janis

    --- Synchronet 3.21a-Linux NewsLink 1.2