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
@@ -8,4 +8,4 @@ class TestSequence is Sequence {
iteratorValue(iterator) { iterator }
}
IO.print((new TestSequence).count) // expect: 10
IO.print(TestSequence.new().count) // expect: 10
+1 -1
View File
@@ -7,4 +7,4 @@ class InfiniteSequence is Sequence {
}
// Should not try to iterate the whole sequence.
IO.print((new InfiniteSequence).isEmpty) // expect: false
IO.print(InfiniteSequence.new().isEmpty) // expect: false
+3 -3
View File
@@ -1,6 +1,6 @@
// Infinite iterator demonstrating that Sequence.map is not eager
class FibIterator {
new {
this new() {
_current = 0
_next = 1
}
@@ -16,7 +16,7 @@ class FibIterator {
class Fib is Sequence {
iterate(iterator) {
if (iterator == null) return new FibIterator
if (iterator == null) return FibIterator.new()
iterator.iterate
return iterator
}
@@ -24,7 +24,7 @@ class Fib is Sequence {
iteratorValue(iterator) { iterator.value }
}
var squareFib = (new Fib).map {|fib| fib * fib }
var squareFib = Fib.new().map {|fib| fib * fib }
var iterator = null
IO.print(squareFib is Sequence) // expect: true
+1 -1
View File
@@ -8,4 +8,4 @@ class TestSequence is Sequence {
iteratorValue(iterator) { iterator }
}
IO.print((new TestSequence).toList) // expect: [1, 2, 3]
IO.print(TestSequence.new().toList) // expect: [1, 2, 3]
+3 -3
View File
@@ -1,6 +1,6 @@
// Infinite iterator demonstrating that Sequence.where is not eager
class FibIterator {
new {
this new() {
_current = 0
_next = 1
}
@@ -16,7 +16,7 @@ class FibIterator {
class Fib is Sequence {
iterate(iterator) {
if (iterator == null) return new FibIterator
if (iterator == null) return FibIterator.new()
iterator.iterate
return iterator
}
@@ -24,7 +24,7 @@ class Fib is Sequence {
iteratorValue(iterator) { iterator.value }
}
var largeFibs = (new Fib).where {|fib| fib > 100 }
var largeFibs = Fib.new().where {|fib| fib > 100 }
var iterator = null
IO.print(largeFibs is Sequence) // expect: true