feat: replace IO class with System class and remove separate IO module

- Delete wren_io.c, wren_io.h, and io.wren source files
- Remove multi-arity print overloads and IO.read/IO.time methods
- Add System class with print, printAll, write, writeAll methods to core.wren
- Update all documentation examples and README to use System.print instead of IO.print
This commit is contained in:
Bob Nystrom
2015-09-15 14:46:09 +00:00
parent f12581a674
commit aa72900a9e
491 changed files with 3285 additions and 3544 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
var f = Fn.new {}
IO.print(f.call()) // expect: null
System.print(f.call()) // expect: null
+1 -1
View File
@@ -1,4 +1,4 @@
var f = Fn.new {
// Hi.
}
IO.print(f.call()) // expect: null
System.print(f.call()) // expect: null
@@ -1,2 +1,2 @@
Fn.new { IO.print("ok") // expect error
Fn.new { System.print("ok") // expect error
}.call()
@@ -1,2 +1,2 @@
Fn.new {
IO.print("ok") } // expect error
System.print("ok") } // expect error
+17 -17
View File
@@ -1,50 +1,50 @@
var f0 = Fn.new { 0 }
IO.print(f0.call()) // expect: 0
System.print(f0.call()) // expect: 0
var f1 = Fn.new {|a| a }
IO.print(f1.call(1)) // expect: 1
System.print(f1.call(1)) // expect: 1
var f2 = Fn.new {|a, b| a + b }
IO.print(f2.call(1, 2)) // expect: 3
System.print(f2.call(1, 2)) // expect: 3
var f3 = Fn.new {|a, b, c| a + b + c }
IO.print(f3.call(1, 2, 3)) // expect: 6
System.print(f3.call(1, 2, 3)) // expect: 6
var f4 = Fn.new {|a, b, c, d| a + b + c + d }
IO.print(f4.call(1, 2, 3, 4)) // expect: 10
System.print(f4.call(1, 2, 3, 4)) // expect: 10
var f5 = Fn.new {|a, b, c, d, e| a + b + c + d + e }
IO.print(f5.call(1, 2, 3, 4, 5)) // expect: 15
System.print(f5.call(1, 2, 3, 4, 5)) // expect: 15
var f6 = Fn.new {|a, b, c, d, e, f| a + b + c + d + e + f }
IO.print(f6.call(1, 2, 3, 4, 5, 6)) // expect: 21
System.print(f6.call(1, 2, 3, 4, 5, 6)) // expect: 21
var f7 = Fn.new {|a, b, c, d, e, f, g| a + b + c + d + e + f + g }
IO.print(f7.call(1, 2, 3, 4, 5, 6, 7)) // expect: 28
System.print(f7.call(1, 2, 3, 4, 5, 6, 7)) // expect: 28
var f8 = Fn.new {|a, b, c, d, e, f, g, h| a + b + c + d + e + f + g + h }
IO.print(f8.call(1, 2, 3, 4, 5, 6, 7, 8)) // expect: 36
System.print(f8.call(1, 2, 3, 4, 5, 6, 7, 8)) // expect: 36
var f9 = Fn.new {|a, b, c, d, e, f, g, h, i| a + b + c + d + e + f + g + h + i }
IO.print(f9.call(1, 2, 3, 4, 5, 6, 7, 8, 9)) // expect: 45
System.print(f9.call(1, 2, 3, 4, 5, 6, 7, 8, 9)) // expect: 45
var f10 = Fn.new {|a, b, c, d, e, f, g, h, i, j| a + b + c + d + e + f + g + h + i + j }
IO.print(f10.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) // expect: 55
System.print(f10.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) // expect: 55
var f11 = Fn.new {|a, b, c, d, e, f, g, h, i, j, k| a + b + c + d + e + f + g + h + i + j + k }
IO.print(f11.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) // expect: 66
System.print(f11.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) // expect: 66
var f12 = Fn.new {|a, b, c, d, e, f, g, h, i, j, k, l| a + b + c + d + e + f + g + h + i + j + k + l }
IO.print(f12.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) // expect: 78
System.print(f12.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) // expect: 78
var f13 = Fn.new {|a, b, c, d, e, f, g, h, i, j, k, l, m| a + b + c + d + e + f + g + h + i + j + k + l + m }
IO.print(f13.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) // expect: 91
System.print(f13.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) // expect: 91
var f14 = Fn.new {|a, b, c, d, e, f, g, h, i, j, k, l, m, n| a + b + c + d + e + f + g + h + i + j + k + l + m + n }
IO.print(f14.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) // expect: 105
System.print(f14.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) // expect: 105
var f15 = Fn.new {|a, b, c, d, e, f, g, h, i, j, k, l, m, n, o| a + b + c + d + e + f + g + h + i + j + k + l + m + n + o }
IO.print(f15.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) // expect: 120
System.print(f15.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) // expect: 120
var f16 = Fn.new {|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 }
IO.print(f16.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) // expect: 136
System.print(f16.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) // expect: 136
+6 -6
View File
@@ -1,25 +1,25 @@
// Single expression body.
Fn.new { IO.print("ok") }.call() // expect: ok
Fn.new { System.print("ok") }.call() // expect: ok
// Curly body.
Fn.new {
IO.print("ok") // expect: ok
System.print("ok") // expect: ok
}.call()
// Multiple statements.
Fn.new {
IO.print("1") // expect: 1
IO.print("2") // expect: 2
System.print("1") // expect: 1
System.print("2") // expect: 2
}.call()
// Extra newlines.
Fn.new {
IO.print("1") // expect: 1
System.print("1") // expect: 1
IO.print("2") // expect: 2
System.print("2") // expect: 2
}.call()