musictheory / NilScript

Objective-C-style language superset of JavaScript with a tiny, simple runtime
Other
50 stars 5 forks source link

3.0: Unify syntax for class inheritance and protocol conformance #156

Closed iccir closed 5 years ago

iccir commented 5 years ago

Currently, we mirror Objective-C syntax for protocol conformance:

@class TheClass : TheSuperclass <TheProtocolA, TheProtocolB>
…
@end

@protocol TheProtocol <TheSuperProtocol>
…
@end

Due to TypeScript's typing system, manually declaring protocol conformance is rare. In the above example, TheClass automatically conforms to TheProtocolA if it implements TheProtocolA's required methods.

To ease syntax highlighting and parsing, we could unify class inheritance and protocol conformance:

@class TheClass : TheSuperclass, TheProtocolA, TheProtocolB
…
@end

@protocol TheProtocol : TheSuperProtocol
…
@end

The following would be errors: 1) A class may not inherit from more than one superclass. 2) A protocol may not "inherit" from a class.