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
@@ -19,7 +19,7 @@ class Foo {
method(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) { a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p}
}
var foo = new Foo
var foo = Foo.new()
IO.print(foo.method) // expect: getter
IO.print(foo.method()) // expect: no args
IO.print(foo.method(1)) // expect: 1
+1 -1
View File
@@ -2,4 +2,4 @@ class Foo {
bar {}
}
IO.print((new Foo).bar) // expect: null
IO.print(Foo.new().bar) // expect: null
+1 -1
View File
@@ -4,4 +4,4 @@ class Foo {
}
}
IO.print((new Foo).thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum) // expect: result
IO.print(Foo.new().thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum) // expect: result
+1 -1
View File
@@ -1010,7 +1010,7 @@ class Foo {
method999 { 1 }
}
var foo = new Foo
var foo = Foo.new()
var result = 0
result = result + foo.method000
result = result + foo.method001
+1 -1
View File
@@ -3,7 +3,7 @@ class Foo {
[a, b] { "subscript " + a + " " + b }
}
var foo = new Foo
var foo = Foo.new()
// Allow newlines after commas and before ")".
IO.print(foo.method("a",
+1 -1
View File
@@ -1,3 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod // expect runtime error: Foo does not implement 'someUnknownMethod'.
Foo.new().someUnknownMethod // expect runtime error: Foo does not implement 'someUnknownMethod'.
@@ -1,3 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) // expect runtime error: Foo does not implement 'someUnknownMethod(_,_,_,_,_,_,_,_,_,_,_)'.
Foo.new().someUnknownMethod(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) // expect runtime error: Foo does not implement 'someUnknownMethod(_,_,_,_,_,_,_,_,_,_,_)'.
@@ -1,3 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod(1, 2) // expect runtime error: Foo does not implement 'someUnknownMethod(_,_)'.
Foo.new().someUnknownMethod(1, 2) // expect runtime error: Foo does not implement 'someUnknownMethod(_,_)'.
@@ -1,3 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod(1) // expect runtime error: Foo does not implement 'someUnknownMethod(_)'.
Foo.new().someUnknownMethod(1) // expect runtime error: Foo does not implement 'someUnknownMethod(_)'.
+1 -1
View File
@@ -18,7 +18,7 @@ class Foo {
- { "prefix -" }
}
var foo = new Foo
var foo = Foo.new()
IO.print(foo + "a") // expect: infix + a
IO.print(foo - "a") // expect: infix - a
IO.print(foo * "a") // expect: infix * a
+2 -2
View File
@@ -6,7 +6,7 @@ class Foo {
static bar(arg) { "on metaclass " + arg }
}
IO.print((new Foo).bar) // expect: on instance
IO.print(Foo.new().bar) // expect: on instance
IO.print(Foo.bar) // expect: on metaclass
IO.print((new Foo).bar("arg")) // expect: on instance arg
IO.print(Foo.new().bar("arg")) // expect: on instance arg
IO.print(Foo.bar("arg")) // expect: on metaclass arg
@@ -7,7 +7,7 @@ class Foo {
[a, b, c]=(value) { "3-subscript setter " + a + " " + b + " " + c + " = " + value }
}
var foo = new Foo
var foo = Foo.new()
IO.print(foo["a"]) // expect: 1-subscript a
IO.print(foo["a", "b"]) // expect: 2-subscript a b
IO.print(foo["a", "b", "c"]) // expect: 3-subscript a b c