ENV: ponylang 0.9.0
From ponylang tutorial
class Wombat
let name: String
var _hunger_level: U64
new create(name': String) =>
name = name'
_hunger_level = 0
new hungry(name': String, hunger': U64) =>
name = name'
_hunger_level = hunger'
tried following, compiler complains: constructor with undefined fields
new create(name': String) =>
hungry(name', 0)
Where to get an exact explanation?
A constructor call in Pony will always create a new object, there are no delegating constructors.
In your example, the call to
hungryisn't applied to the object being initialised increate, but to the newWombatallocated.In Pony pseudo-code, this is what's really happening.