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:
@@ -3,13 +3,13 @@ var g = null
|
||||
|
||||
{
|
||||
var local = "local"
|
||||
f = new Fn {
|
||||
f = Fn.new {
|
||||
IO.print(local)
|
||||
local = "after f"
|
||||
IO.print(local)
|
||||
}
|
||||
|
||||
g = new Fn {
|
||||
g = Fn.new {
|
||||
IO.print(local)
|
||||
local = "after g"
|
||||
IO.print(local)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var f = null
|
||||
|
||||
new Fn {|param|
|
||||
f = new Fn {
|
||||
Fn.new {|param|
|
||||
f = Fn.new {
|
||||
IO.print(param)
|
||||
}
|
||||
}.call("param")
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
// would crash because it walked to the end of the upvalue list (correct), but
|
||||
// then didn't handle not finding the variable.
|
||||
|
||||
new Fn {
|
||||
Fn.new {
|
||||
var a = "a"
|
||||
var b = "b"
|
||||
new Fn {
|
||||
Fn.new {
|
||||
IO.print(b) // expect: b
|
||||
IO.print(a) // expect: a
|
||||
}.call()
|
||||
|
||||
@@ -2,11 +2,11 @@ var F = null
|
||||
|
||||
class Foo {
|
||||
method(param) {
|
||||
F = new Fn {
|
||||
F = Fn.new {
|
||||
IO.print(param)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(new Foo).method("param")
|
||||
Foo.new().method("param")
|
||||
F.call() // expect: param
|
||||
|
||||
@@ -2,7 +2,7 @@ var f = null
|
||||
|
||||
{
|
||||
var local = "local"
|
||||
f = new Fn {
|
||||
f = Fn.new {
|
||||
IO.print(local)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// TODO: Is this right? Shouldn't it resolve to this.local?
|
||||
var foo = null
|
||||
|
||||
{
|
||||
@@ -8,7 +9,7 @@ var foo = null
|
||||
}
|
||||
}
|
||||
|
||||
foo = new Foo
|
||||
foo = Foo.new()
|
||||
}
|
||||
|
||||
foo.method // expect: local
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
var f = null
|
||||
|
||||
new Fn {
|
||||
Fn.new {
|
||||
var a = "a"
|
||||
new Fn {
|
||||
Fn.new {
|
||||
var b = "b"
|
||||
new Fn {
|
||||
Fn.new {
|
||||
var c = "c"
|
||||
f = new Fn {
|
||||
f = Fn.new {
|
||||
IO.print(a)
|
||||
IO.print(b)
|
||||
IO.print(c)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
var local = "local"
|
||||
new Fn {
|
||||
Fn.new {
|
||||
IO.print(local) // expect: local
|
||||
}.call()
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// TODO: Is this right? Shouldn't it resolve to this.local?
|
||||
{
|
||||
var local = "local"
|
||||
class Foo {
|
||||
@@ -6,5 +7,5 @@
|
||||
}
|
||||
}
|
||||
|
||||
(new Foo).method // expect: local
|
||||
Foo.new().method // expect: local
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ var f = null
|
||||
|
||||
{
|
||||
var a = "a"
|
||||
f = new Fn {
|
||||
f = Fn.new {
|
||||
IO.print(a)
|
||||
IO.print(a)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
var a = "a"
|
||||
f = new Fn { IO.print(a) }
|
||||
f = Fn.new { IO.print(a) }
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
var foo = "closure"
|
||||
new Fn {
|
||||
Fn.new {
|
||||
{
|
||||
IO.print(foo) // expect: closure
|
||||
var foo = "shadow"
|
||||
|
||||
Reference in New Issue
Block a user