"IO" -> "System".

Get rid of the separate opt-in IO class and replace it with a core
System class.

- Remove wren_io.c, wren_io.h, and io.wren.
- Remove the flags that disable it.
- Remove the overloads for print() with different arity. (It was an
  experiment, but I don't think it's that useful.)
- Remove IO.read(). That will reappear using libuv in the CLI at some
  point.
- Remove IO.time. Doesn't seem to have been used.
- Update all of the tests, docs, etc.

I'm sorry for all the breakage this causes, but I think "System" is a
better name for this class (it makes it natural to add things like
"System.gc()") and frees up "IO" for referring to the CLI's IO module.
This commit is contained in:
Bob Nystrom
2015-09-15 07:46:09 -07:00
parent 66b89a493f
commit 58e4d26648
491 changed files with 3285 additions and 3544 deletions
+8 -8
View File
@@ -37,7 +37,7 @@ on strings *return* byte indexes too. So, for example, this does what you want:
:::dart
var metalBand = "Fäcëhämmër"
var hPosition = metalBand.indexOf("h")
IO.print(metalBand[hPosition]) // "h"
System.print(metalBand[hPosition]) // "h"
If you want to work with a string as a sequence numeric code points, call the
`codePoints` getter. It returns a [Sequence](sequence.html) that decodes UTF-8
@@ -68,7 +68,7 @@ methods, the returned object also has a subscript operator that can be used to
directly index bytes.
:::dart
IO.print("hello".bytes[1]) // 101, for "e".
System.print("hello".bytes[1]) // 101, for "e".
The `count` method on the returned sequence returns the number of bytes in the
string. Unlike `count` on the string itself, it does not have to iterate over
@@ -83,15 +83,15 @@ single-character strings, this returns the numeric code point values.
:::dart
var string = "(ᵔᴥᵔ)"
IO.print(string.codePoints[0]) // 40, for "(".
IO.print(string.codePoints[4]) // 7461, for "ᴥ".
System.print(string.codePoints[0]) // 40, for "(".
System.print(string.codePoints[4]) // 7461, for "ᴥ".
If the byte at `index` does not begin a valid UTF-8 sequence, or the end of the
string is reached before the sequence is complete, returns `-1`.
:::dart
var string = "(ᵔᴥᵔ)"
IO.print(string.codePoints[2]) // -1, in the middle of "ᵔ".
System.print(string.codePoints[2]) // -1, in the middle of "ᵔ".
### **contains**(other)
@@ -132,7 +132,7 @@ for iterating over the *code points* in the string:
codePoints.add(c)
}
IO.print(codePoints) // ["(", "ᵔ", "ᴥ", "ᵔ", ")"].
System.print(codePoints) // ["(", "ᵔ", "ᴥ", "ᵔ", ")"].
If the string contains any bytes that are not valid UTF-8, this iterates over
those too, one byte at a time.
@@ -162,7 +162,7 @@ Check if the string is not equal to `other`.
Returns a string containing the code point starting at byte `index`.
:::dart
IO.print("ʕ•ᴥ•ʔ"[5]) // "ᴥ".
System.print("ʕ•ᴥ•ʔ"[5]) // "ᴥ".
Since `ʕ` is two bytes in UTF-8 and `•` is three, the fifth byte points to the
bear's nose.
@@ -171,7 +171,7 @@ If `index` points into the middle of a UTF-8 sequence or at otherwise invalid
UTF-8, this returns a one-byte string containing the byte at that index:
:::dart
IO.print("I ♥ NY"[3]) // One-byte string whose value is 153.
System.print("I ♥ NY"[3]) // One-byte string whose value is 153.
It is a runtime error if `index` is greater than the number of bytes in the
string.