Make constructors just methods.

* Eliminate "new" reserved word.
* Allow "this" before a method definition to define a constructor.
* Only create a default constructor for classes that don't define one.
This commit is contained in:
Bob Nystrom
2015-07-10 09:18:22 -07:00
parent 0ddaa2517c
commit 5fb6186d7d
221 changed files with 864 additions and 654 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
var fiber = new Fiber {}
var fiber = Fiber.new {}
var map = {
null: "null value",
+1 -1
View File
@@ -1,4 +1,4 @@
var map = new Map
var map = Map.new()
IO.print(map.count) // expect: 0
IO.print(map) // expect: {}
+1 -1
View File
@@ -12,7 +12,7 @@ class Foo {
toString { "Foo.toString" }
}
IO.print({1: new Foo}) // expect: {1: Foo.toString}
IO.print({1: Foo.new()}) // expect: {1: Foo.toString}
// Since iteration order is unspecified, we don't know what order the results
// will be.