Add TOKEN_CONSTRUCT as a new reserved word in the Wren compiler lexer and parser, and update the grammar rule table so that 'construct' triggers a constructor signature instead of 'this'. Modify all built-in class definitions in core.wren, wren_core.c, benchmark files, and test fixtures to use 'construct new(...)' and 'construct named(...)' syntax. Update documentation in classes.markdown and syntax.markdown to reflect the new keyword, and remove the deprecated test files for 'new' and infix class expressions.
15 lines
327 B
Plaintext
15 lines
327 B
Plaintext
class Foo {
|
|
construct named() { _field = "named" }
|
|
construct other() { _field = "other" }
|
|
|
|
toString { _field }
|
|
}
|
|
|
|
IO.print(Foo.named()) // expect: named
|
|
IO.print(Foo.other()) // expect: other
|
|
|
|
// Returns the new instance.
|
|
var foo = Foo.named()
|
|
IO.print(foo is Foo) // expect: true
|
|
IO.print(foo.toString) // expect: named
|