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
+1 -1
View File
@@ -1,2 +1,2 @@
var f = new Fn {}
IO.print(f.call) // expect: null
IO.print(f.call()) // expect: null
+1 -1
View File
@@ -1,4 +1,4 @@
var f = new Fn {
// Hi.
}
IO.print(f.call) // expect: null
IO.print(f.call()) // expect: null
@@ -1,5 +1,5 @@
new Fn { IO.print("ok") // expect error
}.call // expect error
}.call() // expect error
// The second error is cascaded here. If it starts failing, just remove that
// expectation.
+1
View File
@@ -0,0 +1 @@
new Fn {|| null } // expect error
+1 -1
View File
@@ -1,5 +1,5 @@
var f0 = new Fn { 0 }
IO.print(f0.call) // expect: 0
IO.print(f0.call()) // expect: 0
var f1 = new Fn {|a| a }
IO.print(f1.call(1)) // expect: 1
+4 -4
View File
@@ -1,16 +1,16 @@
// Single expression body.
new Fn { IO.print("ok") }.call // expect: ok
new Fn { IO.print("ok") }.call() // expect: ok
// Curly body.
new Fn {
IO.print("ok") // expect: ok
}.call
}.call()
// Multiple statements.
new Fn {
IO.print("1") // expect: 1
IO.print("2") // expect: 2
}.call
}.call()
// Extra newlines.
new Fn {
@@ -22,4 +22,4 @@ new Fn {
IO.print("2") // expect: 2
}.call
}.call()