This repository has been archived by the owner on Mar 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Classes #5
Comments
class Foo {
let x = 2;
mut a:string;
constructor() {
this("<no message>");
}
constructor(this.message);
factory hello() => new Foo("Hello, world!");
bar():void => printf "Message: %s%n", message;
}
class Bar extends Foo {
@override()
bar():void {
this.message = "Polymorphism... rules!";
super.bar();
}
} Resolving class members without There always will need to be a check to ensure that factory constructors are not called via Overrides will also have to make sure that their signatures match. |
In the future, abstract classes can be added. abstract class Reason {
get name:string; // Requires getter
set name(value:int); // Require setter
precedence:int; // Require both
explain():string;
}
class BaseReason implements Reason {
_name:string;
constructor(this._name);
@override()
get name => _name;
// ...
} |
classDefinition:
classModifier* 'class' name=ID ('extends' parentType=type)?
((implementedTypes+=type ',')* implementedTypes+=type)?
'{' classMemberDefinition* '}'
;
classMemberDefinition:
'constructor' '(' ((constructorParameter)* constructorParameter)? ')' #ConstructorDefinition
| specifier=('let'|'mut') (variableDeclaration ',')* variableDeclaration #PropertyDefinition
| funcSignature ';' #AbstractMethodDefinition
| funcSignature block #MethodDefinition
;
constructorParameter:
'this' '.' ID #PropertyConstructorParameter
| ID (':' type)? #RegularConstructorParameter
;
classModifier: 'abstract' | 'final'; |
Eventually, classes will need to add annotations (#9). |
Open
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
No description provided.
The text was updated successfully, but these errors were encountered: