1
0
forked from Mirror/wren

"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

View File

@ -58,7 +58,7 @@ To find the value associated with some key, again you use your friend the
subscript operator:
:::dart
IO.print(capitals["Idaho"]) // "Boise".
System.print(capitals["Idaho"]) // "Boise".
If the key is present, this returns its value. Otherwise, it returns `null`. Of
course, `null` itself can also be used as a value, so seeing `null` here
@ -69,15 +69,15 @@ To tell definitively if a key exists, you can call `containsKey()`:
:::dart
var belief = {"nihilism": null}
IO.print(belief["nihilism"]) // "null" though key exists.
IO.print(belief["solipsism"]) // Also "null".
IO.print(belief.containsKey("nihilism")) // "true".
IO.print(belief.containsKey("solipsism")) // "false".
System.print(belief["nihilism"]) // "null" though key exists.
System.print(belief["solipsism"]) // Also "null".
System.print(belief.containsKey("nihilism")) // "true".
System.print(belief.containsKey("solipsism")) // "false".
You can see how many entries a map contains using `count`:
:::dart
IO.print(capitals.count) // "3".
System.print(capitals.count) // "3".
## Removing entries
@ -86,12 +86,12 @@ entry you want to delete:
:::dart
capitals.remove("Maine")
IO.print(capitals.containsKey("Maine")) // "false".
System.print(capitals.containsKey("Maine")) // "false".
If the key was found, this returns the value that was associated with it:
:::dart
IO.print(capitals.remove("Georgia")) // "Atlanta".
System.print(capitals.remove("Georgia")) // "Atlanta".
If the key wasn't in the map to begin with, `remove()` just returns `null`.
@ -100,7 +100,7 @@ can just call `clear()`:
:::dart
capitals.clear()
IO.print(capitals.count) // "0".
System.print(capitals.count) // "0".
[lists]: lists.html
@ -120,14 +120,14 @@ If you want to see all of the key-value pairs in a map, the easiest way is to
iterate over the keys and use each to look up its value:
:::dart
var stateBirds = {
var birds = {
"Arizona": "Cactus wren",
"Hawaii": "Nēnē",
"Ohio": "Northern Cardinal"
}
for (state in stateBirds.keys) {
IO.print("The state bird of ", state, " is ", stateBirds[state])
for (state in birds.keys) {
System.print("The state bird of " + state + " is " + birds[state])
}
This program will print the three states and their birds. However, the *order*