musictheory / NilScript

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

3.0: Investigate more consistent type syntax #145

Closed iccir closed 5 years ago

iccir commented 6 years ago

Right now, we have 3 different syntaxes for type annotations:

  1. C-style (used by @class ivars and @property)
  2. "Method-style" (used in method definitions and declarations)
  3. TypeScript-style (used by functions, @type, and variables).

Trying to use TypeScript-style for methods is going to be weird (since the : is part of the method signature. Could/should we use TypeScript-style for ivars and possibly @property?

This solves a frequent issue I hit: confusing syntax when converting between an @type and @class.

iccir commented 6 years ago

An example of converting ivars and properties to Typescript-style:

@class TheClass {
    _aString: String;
    _bString: String, _cString: String;
    _checked: BOOL;
}

@property (readonly) theProperty: String;

@end