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

Extension methods #3

Open
jchitel opened this issue Nov 9, 2017 · 0 comments
Open

Extension methods #3

jchitel opened this issue Nov 9, 2017 · 0 comments

Comments

@jchitel
Copy link
Owner

jchitel commented Nov 9, 2017

Extensions

Dependencies: Overloads, Interfaces

New syntactic features:

New Tokens:

WITH ::= with
THIS ::= this
DOUBLE_COLON ::= ::

New NonTerminals:

MethodDeclaration ::= Type IDENT TypeParamList? ParameterList FAT_ARROW (Expression | Statement)
MethodInvoation ::= Expression DOT IDENT TypeArgList? LPAREN (Expression (COMMA Expression)*)? RPAREN
MethodReference ::= Expression DOUBLE_COLON IDENT

Extended NonTerminals:

Type ::= Type WITH LBRACE MethodDeclaration* RBRACE
Expression ::= THIS
             | MethodInvocation
             | MethodReference

New semantic features:

  • Extensions add methods to types
  • Methods are functions "bound" to a type, and can be called with a method invocation
  • Methods can also be referenced using a method reference expression
  • Methods can use the 'this' expression to refer to the instance of the type it was invoked on
  • Extensions include the methods as part of the types, and are included in interface assignability checks
  • Assignability to extensions ignores the methods, based on structure only

Transformation:

  • Will require invocation instruction and method reference instruction
@jchitel jchitel self-assigned this Nov 9, 2017
@jchitel jchitel added this to To Do in Ren v0.1 via automation Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Ren v0.1
  
To Do
Development

No branches or pull requests

1 participant