"modals" in Algol68

15 views
Skip to first unread message

Bakul Shah

unread,
Dec 21, 2021, 1:43:41 PM12/21/21
to
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.

Andy Walker

unread,
Dec 21, 2021, 4:21:54 PM12/21/21
to
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

Bakul Shah

unread,
Dec 21, 2021, 6:06:50 PM12/21/21
to
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.

Charles Lindsey

unread,
Dec 22, 2021, 10:11:22 AM12/22/21
to
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: c...@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

Bakul Shah

unread,
Dec 22, 2021, 11:10:47 AM12/22/21
to
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
Reply all
Reply to author
Forward
0 new messages