Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support protocols and typed arrays #31

Closed
iccir opened this issue Nov 10, 2014 · 1 comment
Closed

Support protocols and typed arrays #31

iccir opened this issue Nov 10, 2014 · 1 comment

Comments

@iccir
Copy link
Member

iccir commented Nov 10, 2014

Add support for protocols (id<ProtocolName>) for method parameters, ivars, @properties, etc. This will be for documentation purposes at first. With the addition of union types in TypeScript, we could also possibly add this to the typechecker.

Additionally, the same parsing code can handle typed arrays: Array<String> for an Array of String objects.

I'm hesitant to add generics or expose TypeScript's generic types/functions, but I think making a one-time exception for Array is worth it. Since there is no way for an oj class to subclass the native Array type, the angle bracket syntax on Array will never indicate a protocol. This will need to be evaluated for Set in ECMAScript 6. Also, if type annotations make it into ECMAScript 7, we might need to support that syntax in addition for typed arrays.

@iccir
Copy link
Member Author

iccir commented Nov 10, 2014

To be specific, the following currently fail to parse:

- (void) aMethod:(id<Foo>)arg { }
@property id<Foo, Bar> property;
@property Foo<Foo<Bar>> property;
@property Foo<Baz, Foo<Bar>> property;

This issue is simply about making these cases succeed at parse time. The oj compiler will then immediately throw out this type information (the only time type information affects codegen is for numeric/boolean ivars, which are initialized to 0/false. These are all object types, so as ivars they would be initialized to null).

The part above regarding Array typing is for the experimental type checker. As everything else with the type checker, it's subject to change ;)

iccir added a commit that referenced this issue Nov 10, 2014
@iccir iccir closed this as completed Nov 10, 2014
iccir added a commit that referenced this issue Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant