Thursday, January 21, 2010

Happy with that!

Here is the definition of zero, the prototype for all numbers (integer ones at least...)

(constructor zero: vm

(function addValue: addedValue
numberFrom: ($vm add: $addedValue to: $value)
)

(function plus: number
addValue: ($number value)
)

(function minus: number
numberFrom: ($vm subtract: ($number value) from: $value)
)

(function isLessThan: number
$vm value: $value isLessThan: ($number value)
)

(function value // not so happy with this, but not end of world..
$value
)

(function numberFrom: value
numberConstructor: value prototype: $this
)

(constructor numberConstructor: value prototype: numberPrototype
parent: $numberPrototype
)

$value: .0
)

I really like it. I was initially doing all kinds of stuff creating prototypes, but that's too classical inheritance - zero IS the prototype. I like.

I think this is easier to read as well. (you didn't see it before, did you :)

Also I've put list onto Activation, but haven't immutabled it yet

No comments:

Post a Comment