Use more conventional syntax for constructors.

They are now invoked like "new Foo".
Also, superclass constructors are now much less semantically
and syntactically weird. Since the instance is created before
any constructor is called, there's no point in time where the
instance isn't there.
This commit is contained in:
Bob Nystrom
2013-12-19 07:02:27 -08:00
parent b880b17db9
commit 4d67f2270a
30 changed files with 171 additions and 190 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ class Foo {
method(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) { return a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p}
}
var foo = Foo.new
var foo = new Foo
io.write(foo.method) // expect: 0
io.write(foo.method(1)) // expect: 1
io.write(foo.method(1, 2)) // expect: 3
+1 -1
View File
@@ -4,4 +4,4 @@ class Foo {
}
}
io.write(Foo.new.thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum) // expect: result
io.write((new Foo).thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum) // expect: result
+1 -1
View File
@@ -15,7 +15,7 @@ class Foo {
- { return "prefix -" }
}
var foo = Foo.new
var foo = new Foo
io.write(foo + "a") // expect: infix + a
io.write(foo - "a") // expect: infix - a
io.write(foo * "a") // expect: infix * a
+4 -5
View File
@@ -6,8 +6,7 @@ class Foo {
static bar(arg) { return "on metaclass " + arg }
}
io.write("on metaclass " + "arg") // expect: on metaclass arg
io.write(Foo.new.bar) // expect: on instance
io.write(Foo.bar) // expect: on metaclass
io.write(Foo.new.bar("arg")) // expect: on instance arg
io.write(Foo.bar("arg")) // expect: on metaclass arg
io.write((new Foo).bar) // expect: on instance
io.write(Foo.bar) // expect: on metaclass
io.write((new Foo).bar("arg")) // expect: on instance arg
io.write(Foo.bar("arg")) // expect: on metaclass arg