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:
@@ -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)
|
||||
|
||||
@@ -11,7 +11,7 @@ class Derived is Base {
|
||||
}
|
||||
}
|
||||
|
||||
(new Derived).bar
|
||||
Derived.new().bar
|
||||
// expect: Derived.bar
|
||||
// expect: Base.foo
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@ class Derived is Base {
|
||||
}
|
||||
}
|
||||
|
||||
(new Derived).foo
|
||||
Derived.new().foo
|
||||
// expect: Derived.foo
|
||||
// expect: Base.foo
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user