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
+4 -2
View File
@@ -1,5 +1,6 @@
class Foo {
method { 0 }
method { "getter" }
method() { "no args" }
method(a) { a }
method(a, b) { a + b }
method(a, b, c) { a + b + c }
@@ -19,7 +20,8 @@ class Foo {
}
var foo = new Foo
IO.print(foo.method) // expect: 0
IO.print(foo.method) // expect: getter
IO.print(foo.method()) // expect: no args
IO.print(foo.method(1)) // expect: 1
IO.print(foo.method(1, 2)) // expect: 3
IO.print(foo.method(1, 2, 3)) // expect: 6
+3
View File
@@ -0,0 +1,3 @@
var list = [1, 2]
list[] // expect error
"don't actually want error here, but cascades from above" // expect error
@@ -0,0 +1,3 @@
class Foo {
[] { "empty" } // expect error
}