feat: allow empty argument list methods in calls, definitions, and docs

- Compile empty `()` as a valid method signature distinct from no parentheses
- Update `call()`, `clear()`, `run()`, `try()`, and `yield()` to use empty argument lists
- Revise documentation across multiple files to reflect new signature semantics
This commit is contained in:
Bob Nystrom
2015-02-27 07:08:36 +00:00
parent 94f34367f9
commit 5382fa05d7
94 changed files with 291 additions and 224 deletions
+16 -15
View File
@@ -13,7 +13,7 @@ fiber is run. Does not immediately start running the fiber.
IO.print("I won't get printed")
}
### Fiber.**yield**
### Fiber.**yield**()
Pauses the current fiber and transfers control to the parent fiber. "Parent"
here means the last fiber that was started using `call` and not `run`.
@@ -21,37 +21,38 @@ here means the last fiber that was started using `call` and not `run`.
:::dart
var fiber = new Fiber {
IO.print("Before yield")
Fiber.yield
Fiber.yield()
IO.print("After yield")
}
fiber.call // "Before yield"
fiber.call() // "Before yield"
IO.print("After call") // "After call"
fiber.call // "After yield"
fiber.call() // "After yield"
When resumed, the parent fiber's `call` method returns `null`.
When resumed, the parent fiber's `call()` method returns `null`.
If a yielded fiber is resumed by calling `call()` or `run()` with an argument,
`yield` returns that value.
`yield()` returns that value.
:::dart
var fiber = new Fiber {
IO.print(Fiber.yield) // "value"
IO.print(Fiber.yield()) // "value"
}
fiber.call // Run until the first yield.
fiber.call() // Run until the first yield.
fiber.call("value") // Resume the fiber.
If it was resumed by calling `call` or `run` with no argument, returns `null`.
If it was resumed by calling `call()` or `run()` with no argument, it returns
`null`.
It is a runtime error to call this when there is no parent fiber to return to.
:::dart
Fiber.yield // ERROR
Fiber.yield() // ERROR
new Fiber {
Fiber.yield // ERROR
}.run
Fiber.yield() // ERROR
}.run()
### Fiber.**yield**(value)
@@ -63,9 +64,9 @@ Similar to `Fiber.yield` but provides a value to return to the parent fiber's
Fiber.yield("value")
}
IO.print(fiber.call) // "value"
IO.print(fiber.call()) // "value"
### **call**
### **call**()
**TODO**
@@ -78,7 +79,7 @@ Similar to `Fiber.yield` but provides a value to return to the parent fiber's
Whether the fiber's main function has completed and the fiber can no longer be
run. This returns `false` if the fiber is currently running or has yielded.
### **run**
### **run**()
**TODO**
+1 -1
View File
@@ -9,7 +9,7 @@ An indexable contiguous collection of elements. More details [here](../lists.htm
Appends `item` to the end of the list.
### **clear**
### **clear**()
Removes all items from the list.
+1 -1
View File
@@ -3,7 +3,7 @@
An associative collection that maps keys to values. More details [here](../maps.html).
### **clear**
### **clear**()
Removes all entries from the map.