• "modals" in Algol68

    From Bakul Shah@21:1/5 to All on Tue Dec 21 10:43:37 2021
    Q for the Algol68 experts/historians on this group:

    Looking at C.H.Lindsey's "Modals" in https://archive.computerhistory.org/resources/text/algol/algol_bulletin/A37/P43.HTM

    It seems this is basically describing generic types and functions.
    For example,

    MODE LINK = (MODE X) STRUCT ( REF X name, REF LINK(X) next);

    So LINK is a modal while LINK(INT) would be a mode, right?

    Was this ever implemented or considered seriously for one?
    How would have they handled operations on variables of such
    mode? That is, if a function body uses, for example, +, then
    only modes that have + defined on them can be used as a mode
    "parameter". In particular comparison operators would be
    needed for a generic sort procedure!

    Just curious.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andy Walker@21:1/5 to Bakul Shah on Tue Dec 21 21:21:51 2021
    On 21/12/2021 18:43, Bakul Shah wrote:
    Looking at C.H.Lindsey's "Modals" in https://archive.computerhistory.org/resources/text/algol/algol_bulletin/A37/P43.HTM
    It seems this is basically describing generic types and functions.
    For example,
    MODE LINK = (MODE X) STRUCT ( REF X name, REF LINK(X) next);
    So LINK is a modal while LINK(INT) would be a mode, right?

    That's my understanding [but based almost entirely on the
    article you mention].

    Was this ever implemented or considered seriously for one?

    As Charles says, it is believed to have been implemented
    in Mary. I don't have the Mary book, and Wiki is silent on the
    matter. I "invited" Marcel to implement it for A68G, but he
    didn't bite; I didn't push him as to whether this was because it
    was too difficult, or too uninteresting [to him]. So, AFAIK, it
    has never been implemented in an A68 dialect. Charles may well
    know more.

    How would have they handled operations on variables of such
    mode? That is, if a function body uses, for example, +, then
    only modes that have + defined on them can be used as a mode
    "parameter". In particular comparison operators would be
    needed for a generic sort procedure!

    Note that the modal is only ever used as a reference.
    So you can implement generic queues and similar, but [as per
    the example in AB] a generic sort procedure needs a handler
    routine to do the comparisons. IOW, it's quite a limited
    facility, but "interesting" and occasionally useful. As
    noted in Charles's paper, the limitations need exploration;
    I'm not aware of any more advanced proposal. For the AB
    proposal, you have to imagine that any code using a modal
    has been pre-compiled, and so knows nothing about how it is
    to be used in your program. That seems to resolve most
    questions. [The point about references is that, in most
    implementations, the compiler may have no idea how big an
    array or a structure will be (in code yet to be written),
    but it's likely that it knows how big a pointer to them
    will be, so that's what can be compiled.]

    --
    Andy Walker, Nottingham.
    Andy's music pages: www.cuboid.me.uk/andy/Music
    Composer of the day: www.cuboid.me.uk/andy/Music/Composers/Ravel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bakul Shah@21:1/5 to Andy Walker on Tue Dec 21 15:06:46 2021
    On 12/21/21 1:21 PM, Andy Walker wrote:
    On 21/12/2021 18:43, Bakul Shah wrote:
    Looking at C.H.Lindsey's "Modals" in
    https://archive.computerhistory.org/resources/text/algol/algol_bulletin/A37/P43.HTM
    It seems this is basically describing generic types and functions.
    For example,
    MODE LINK = (MODE X) STRUCT ( REF X name, REF LINK(X) next);
    So LINK is a modal while LINK(INT) would be a mode, right?

        That's my understanding [but based almost entirely on the
    article you mention].

    Was this ever implemented or considered seriously for one?

        As Charles says, it is believed to have been implemented
    in Mary.  I don't have the Mary book, and Wiki is silent on the
    matter.  I "invited" Marcel to implement it for A68G, but he
    didn't bite;  I didn't push him as to whether this was because it
    was too difficult, or too uninteresting [to him].  So, AFAIK, it
    has never been implemented in an A68 dialect.  Charles may well
    know more.

    Thanks! As it happens, a few years ago I came to know one of the
    people involved in the Mary language design so I have asked him.

    How would have they handled operations on variables of such
    mode? That is, if a function body uses, for example, +, then
    only modes that have + defined on them can be used as a mode
    "parameter". In particular comparison operators would be
    needed for a generic sort procedure!

        Note that the modal is only ever used as a reference.
    So you can implement generic queues and similar, but [as per
    the example in AB] a generic sort procedure needs a handler
    routine to do the comparisons.  IOW, it's quite a limited
    facility, but "interesting" and occasionally useful.  As
    noted in Charles's paper, the limitations need exploration;
    I'm not aware of any more advanced proposal.  For the AB
    proposal, you have to imagine that any code using a modal
    has been pre-compiled, and so knows nothing about how it is
    to be used in your program.  That seems to resolve most
    questions.  [The point about references is that, in most
    implementations, the compiler may have no idea how big an
    array or a structure will be (in code yet to be written),
    but it's likely that it knows how big a pointer to them
    will be, so that's what can be compiled.]

    I believe you can do do this at compile time (think proper
    macros) but you'd need the source of the generic library.
    The compiler would have to store the requirements somehow
    so that it can provide an error message at the use site,
    in case of passing the wrong type to a generic type/function.
    Or the language can provide a way to indicate this.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Charles Lindsey@21:1/5 to Bakul Shah on Wed Dec 22 15:11:19 2021
    On 21/12/2021 23:06, Bakul Shah wrote:
    On 12/21/21 1:21 PM, Andy Walker wrote:
    On 21/12/2021 18:43, Bakul Shah wrote:
    Looking at C.H.Lindsey's "Modals" in
    https://archive.computerhistory.org/resources/text/algol/algol_bulletin/A37/P43.HTM
    It seems this is basically describing generic types and functions.
    For example,
    MODE LINK = (MODE X) STRUCT ( REF X name, REF LINK(X) next);
    So LINK is a modal while LINK(INT) would be a mode, right?

         That's my understanding [but based almost entirely on the
    article you mention].

    Was this ever implemented or considered seriously for one?

         As Charles says, it is believed to have been implemented
    in Mary.  I don't have the Mary book, and Wiki is silent on the
    matter.  I "invited" Marcel to implement it for A68G, but he
    didn't bite;  I didn't push him as to whether this was because it
    was too difficult, or too uninteresting [to him].  So, AFAIK, it
    has never been implemented in an A68 dialect.  Charles may well
    know more.

    No, I have heard or done nothing concerning modals since the paper was written, and the posts in this thread have already covered most of the issues. Essentially modals in Algol 68 are equivalent to templates in C++, which we have
    discussed here several times.

    I had the Mary book at one time, but if you want to read it you will have to go to California since all my papers have been donated to the Computer History Museum.

    Thanks! As it happens, a few years ago I came to know one of the
    people involved in the Mary language design so I have asked him.

    Was that Mark Rains? Let us know if anything comes back from that source.

    My chief memory of Mark Rains is his very quotable remark:

    "Algol 68 is Complex;
    PL/1 is Complicated."


    --
    Charles H. Lindsey ---------At my New Home, still doing my own thing------
    Tel: +44 161 488 1845 Web: https://www.clerew.man.ac.uk Email: chl@clerew.man.ac.uk Snail-mail: Apt 40, SK8 5BF, U.K.
    PGP: 2C15F1A9 Fingerprint: 73 6D C2 51 93 A0 01 E7 65 E8 64 7E 14 A4 AB A5

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bakul Shah@21:1/5 to Charles Lindsey on Wed Dec 22 08:10:43 2021
    On 12/22/21 7:11 AM, Charles Lindsey wrote:
    On 21/12/2021 23:06, Bakul Shah wrote:
    On 12/21/21 1:21 PM, Andy Walker wrote:
    On 21/12/2021 18:43, Bakul Shah wrote:
    Looking at C.H.Lindsey's "Modals" in
    https://archive.computerhistory.org/resources/text/algol/algol_bulletin/A37/P43.HTM
    It seems this is basically describing generic types and functions.
    For example,
    MODE LINK = (MODE X) STRUCT ( REF X name, REF LINK(X) next);
    So LINK is a modal while LINK(INT) would be a mode, right?

         That's my understanding [but based almost entirely on the
    article you mention].

    Was this ever implemented or considered seriously for one?

         As Charles says, it is believed to have been implemented
    in Mary.  I don't have the Mary book, and Wiki is silent on the
    matter.  I "invited" Marcel to implement it for A68G, but he
    didn't bite;  I didn't push him as to whether this was because it
    was too difficult, or too uninteresting [to him].  So, AFAIK, it
    has never been implemented in an A68 dialect.  Charles may well
    know more.

    No, I have heard or done nothing concerning modals since the paper was written, and the posts in this thread have already covered most of the issues. Essentially modals in Algol 68 are equivalent to templates in
    C++, which we have discussed here several times.

    Thanks.

    I had the Mary book at one time, but if you want to read it you will
    have to go to California since all my papers have been donated to the Computer History Museum.

    CHM is about 5 miles from my home, though temporarily closed due to
    the coronavirus. At CHM online I did find Mark Rains' paper on "Some
    formal aspects of MARY or Algol X revisited" which seems to explain
    its differences from Algol68.


    Thanks! As it happens, a few years ago I came to know one of the
    people involved in the Mary language design so I have asked him.

    Was that Mark Rains? Let us know if anything comes back from that source.

    Yes, indeed. Now known as Ivan Godard. He has been working on a new
    & very interesting processor architecture called Mill for the past many
    years. He occasionally posts on comp.arch.

    He did respond. In part he said "Modals were declarable LL1 syntax with
    value name binding for the runtime arguments; you passed a pointer or
    thunk for other kinds of binding. Because both types and syntax could
    be arguments too, modals were both weaker and stronger than C++
    templates. There was no automatic partial parameterization. Coercions
    could be chained arbitrarily to achieve a desired type. Coercions were declarable; all contexts were fixed by the language."

    My chief memory of Mark Rains is his very quotable remark:

       "Algol 68 is Complex;
        PL/1 is Complicated."

    Funny, sad & true! I never had a chance to use A68 but at one point
    I knew PL/I pretty well.

    Thanks for your response!

    Bakul

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)