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
@@ -13,7 +13,7 @@ class Derived is Base {
}
}
(new Derived).foo(1)
Derived.new().foo(1)
// expect: Derived.bar(a)
// expect: Base.foo
// expect: Base.foo(a)
+1 -1
View File
@@ -11,7 +11,7 @@ class Derived is Base {
}
}
(new Derived).bar
Derived.new().bar
// expect: Derived.bar
// expect: Base.foo
+1 -1
View File
@@ -11,6 +11,6 @@ class Derived is Base {
}
}
(new Derived).foo
Derived.new().foo
// expect: Derived.foo
// expect: Base.foo
+2 -2
View File
@@ -3,9 +3,9 @@ class Base {
}
class Derived is Base {
getClosure { new Fn { super.toString } }
getClosure { Fn.new { super.toString } }
toString { "Derived" }
}
var closure = (new Derived).getClosure
var closure = Derived.new().getClosure
IO.print(closure.call()) // expect: Base
+1 -1
View File
@@ -11,6 +11,6 @@ class Derived is Base {
}
}
(new Derived).foo
Derived.new().foo
// expect: Derived.foo
// expect: Base.foo
@@ -13,6 +13,6 @@ class C is B {
}
}
(new C).foo
C.new().foo
// expect: C.foo
// expect: A.foo
@@ -4,4 +4,4 @@ class Derived is Base {
foo { super.doesNotExist(1) } // expect runtime error: Base does not implement 'doesNotExist(_)'.
}
(new Derived).foo
Derived.new().foo
@@ -1,6 +1,6 @@
class A {
callSuperToString {
return new Fn { super.toString }.call()
return Fn.new { super.toString }.call()
}
toString { "A.toString" }
@@ -8,4 +8,4 @@ class A {
class B is A {}
IO.print((new B).callSuperToString) // expect: instance of B
IO.print(B.new().callSuperToString) // expect: instance of B
@@ -6,4 +6,4 @@ class A {
class B is A {}
IO.print((new B).callSuperToString) // expect: instance of B
IO.print(B.new().callSuperToString) // expect: instance of B
@@ -1,3 +1,3 @@
new Fn {
Fn.new {
super.foo // expect error
}