Sample code to set an initializer to "_new"
new P10, .PerlString
set P10, "_new"
newclass P1, "Foo"
setprop P1, "BUILD", P10
The BUILD initializer is called for all parents as "__init" was. There
is additionally a "CONSTRUCT" initializer, which is only called for the
top-level class.
The instantiation "new Pobj, Iclass" can now take an additional
initializer too:
new Pobj, Iclass, PInit
This initializer is available as first param in the init method.
Comments welcome,
leo
I'm happy with this. A similar scheme will work nicely for
deconstructors.
(I looked for where to make this possible, but didn't see any obvious
hooks.)
-- c
> I'm happy with this.
Good.
> ... A similar scheme will work nicely for
> deconstructors.
> (I looked for where to make this possible, but didn't see any obvious
> hooks.)
We don't have it yet. We could use vtable->destroy but I'd rather have
vtable->finalize. ->destroy does low-level cleanup of Parrot classes
(i.e. free(3) memory. ->finalize (a distinct vtable method) could do the
higher-level object finalization. Here could be also the place, where
"destruction" ordering is done.
> -- c
leo
> >> This initializer is available as first param in the init method.
> > I'm happy with this.
> Good.
What needs to be done before making it the default? I'm anxious to
remove CALL__BUILD=1 from my parrot alias.
> We don't have it yet. We could use vtable->destroy but I'd rather have
> vtable->finalize. ->destroy does low-level cleanup of Parrot classes
> (i.e. free(3) memory. ->finalize (a distinct vtable method) could do the
> higher-level object finalization. Here could be also the place, where
> "destruction" ordering is done.
That sounds reasonable. It'd certainly be nice to be able to free the
memory of external resources I hold in SDL::* objects.
-- c
> What needs to be done before making it the default? I'm anxious to
> remove CALL__BUILD=1 from my parrot alias.
Waiting for famous final words by our big cheese...
leo