feat: replace new keyword with this constructor syntax and ClassName.new() calls across core library and docs

Replace all uses of the `new` reserved word with explicit `this new()` constructor definitions and `ClassName.new()` instantiation calls in builtin/core.wren. Update all documentation files (classes.markdown, fiber.markdown, fn.markdown, sequence.markdown, error-handling.markdown, expressions.markdown, fibers.markdown, functions.markdown) to reflect the new constructor syntax, removing `new` keyword examples and replacing them with `ClassName.new()` patterns and `this new()` definitions.
This commit is contained in:
Bob Nystrom
2015-07-10 16:18:22 +00:00
parent 121d39cb42
commit e19ff59cce
221 changed files with 864 additions and 654 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
new Fn {
Fn.new {
IO.print(1) // expect: 1
IO.print(2) // expect: 2
IO.print(3) // expect: 3
+1 -1
View File
@@ -1,4 +1,4 @@
var f = new Fn {
var f = Fn.new {
1
2
3
+2 -2
View File
@@ -1,5 +1,5 @@
class Foo {
new {
this new() {
_field1 = 1
_field2 = 2
_field3 = 3
@@ -259,4 +259,4 @@ class Foo {
}
}
var foo = new Foo // expect: 255
var foo = Foo.new() // expect: 255
+4 -4
View File
@@ -1,5 +1,5 @@
class Foo {
new {
this new() {
_field1 = 1
_field2 = 2
_field3 = 3
@@ -137,8 +137,8 @@ class Foo {
}
class Bar is Foo {
new {
super
this new() {
super()
_field129 = 129
_field130 = 130
_field131 = 131
@@ -274,7 +274,7 @@ class Bar is Foo {
}
}
var bar = new Bar
var bar = Bar.new()
bar.foo // expect: 1
// expect: 128
bar.bar // expect: 129
+1 -1
View File
@@ -1,4 +1,4 @@
var f = new Fn {
var f = Fn.new {
1
2
3
+2 -2
View File
@@ -1,5 +1,5 @@
class Foo {
new {
this new() {
_field1 = 1
_field2 = 2
_field3 = 3
@@ -259,4 +259,4 @@ class Foo {
}
}
var foo = new Foo
var foo = Foo.new()
+4 -4
View File
@@ -1,5 +1,5 @@
class Foo {
new {
this new() {
_field1 = 1
_field2 = 2
_field3 = 3
@@ -137,8 +137,8 @@ class Foo {
}
class Bar is Foo { // expect runtime error: Class 'Bar' may not have more than 255 fields, including inherited ones.
new {
super
this new() {
super()
_field129 = 129
_field130 = 130
_field131 = 131
@@ -275,6 +275,6 @@ class Bar is Foo { // expect runtime error: Class 'Bar' may not have more than 2
}
}
var bar = new Bar
var bar = Bar.new()
bar.foo
bar.bar