gracelang / language

Design of the Grace language and its libraries
GNU General Public License v2.0
6 stars 1 forks source link

Remove exception allowing interface keyword to be optional #177

Closed apblack closed 1 year ago

apblack commented 5 years ago

We currently have an odd exception when writing interface literals: when an interface Literal is the only thing on the right-hand-side of a type declaration, it's legal to omit the leading interface keyword.

This exception is codified in the following rules:

TypeDeclaration 
        ::= "type" Identifier TypeParameterList Annotations "=" TypeExpression
        |   "type" Identifier TypeParameterList Annotations "=" InterfaceLiteral

Interface ::= "interface" InterfaceLiteral

InterfaceLiteral ::= "{" "}" |  "{" Signature  ( Ss Signature )*  "}"

TypeExpression ::= Type | ...

Type ::= UnknownType | SelfType | Interface | ...

The reason for this exception is backward compatibility with an older syntax where types were interfaces, and there was no interface reserved word.

I believe that it is time we got rid of this exception. Interfaces should always have the leading interface reserved word. The exception creates confusion in the minds of new contributors (see, for example, gracelang/minigrace#291), makes the grammar more complicated than necessary (the distinction between an Interface and and an InterfaceLiteral, and the two alternatives for TypeDeclaration), and correspondingly complicates the parser. More importantly, it breaks our rule about readability being more important than writability.

kjx commented 5 years ago

I thought we'd already decided to do that, and amg was just keeping backwards compatibility

apblack commented 5 years ago

I don't know what "amg" is, but my recollection was that Kim wanted to keep this exception permanatly. (If I'm wrong, that's great.) The backwards compatibility concession that I remember was allowing type in place of interface. This was removed in d100bf7 (July 2018), when the SmallGrace parser showed that it was ambiguous.

kjx commented 5 years ago

I don't know what "amg"

Andrew's minigrace

The backwards compatibility concession that I remember was allowing type in place of interface.

I can't remember. we should get rid of it anyway.

apblack commented 5 years ago

I don't know what "amg" Andrew's minigrace

Andrew’s minigrace hasn’t seen a commit in almost 3 years. I don’t think that it’s relevant any more.

I would like to have @kimBruce’s approval before removing it.

apblack commented 4 years ago

I would still like to have @KimBruce’s approval before removing this exception.

KimBruce commented 4 years ago

OK, go ahead. We've been adding interface in all those circumstances anyway (though I suspect the text will need lot of modifications, sigh).

apblack commented 1 year ago

The grammar was fixed to remove the interface non-terminal in commit bd3062a (on 6 July 2020). This issue should have been closed at that time.

KimBruce commented 1 year ago

I believe we did agree on this, though I see I did not change the example in "Programming with Grace".

On Sun, Nov 27, 2022 at 2:15 PM Andrew Black @.***> wrote:

Closed #177 https://github.com/gracelang/language/issues/177 as completed.

— Reply to this email directly, view it on GitHub https://github.com/gracelang/language/issues/177#event-7898248494, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN2D6UO4ESLONDY3MJYHYDWKPMQHANCNFSM4HWWIE4A . You are receiving this because you were mentioned.Message ID: @.***>

-- Prof. Kim Bruce Computer Science Pomona College