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:
@@ -1,5 +1,5 @@
|
||||
class Toggle {
|
||||
this new(startState) {
|
||||
new(startState) {
|
||||
_state = startState
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ class Toggle {
|
||||
}
|
||||
|
||||
class NthToggle is Toggle {
|
||||
this new(startState, maxCounter) super.new(startState) {
|
||||
new(startState, maxCounter) {
|
||||
super(startState)
|
||||
_countMax = maxCounter
|
||||
_count = 0
|
||||
}
|
||||
@@ -31,7 +32,7 @@ var start = OS.clock
|
||||
var n = 1000000
|
||||
var i = 0
|
||||
var val = true
|
||||
var toggle = Toggle.new(val)
|
||||
var toggle = new Toggle(val)
|
||||
|
||||
while (i < n) {
|
||||
val = toggle.activate.value
|
||||
@@ -41,7 +42,7 @@ while (i < n) {
|
||||
io.write(toggle.value)
|
||||
|
||||
val = true
|
||||
var ntoggle = NthToggle.new(val, 3)
|
||||
var ntoggle = new NthToggle(val, 3)
|
||||
|
||||
i = 0
|
||||
while (i < n) {
|
||||
|
||||
Reference in New Issue
Block a user