Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

{CVS ci] alternate object initializer calling scheme

6 views
Skip to first unread message

Leopold Toetsch

unread,
Apr 9, 2004, 7:56:32 AM4/9/04
to P6I
I've put in the new scheme for initializer calls.
To test it, set the environment variable "CALL__BUILD" to some value.

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

Chromatic

unread,
Apr 9, 2004, 9:00:46 PM4/9/04
to Leopold Toetsch, P6I

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

Leopold Toetsch

unread,
Apr 10, 2004, 4:49:36 AM4/10/04
to Chromatic, perl6-i...@perl.org
Chromatic <chro...@wgz.org> wrote:
> On Fri, 2004-04-09 at 04:56, Leopold Toetsch wrote:
>>
>> new Pobj, Iclass, PInit
>>
>> This initializer is available as first param in the init method.

> 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

Chromatic

unread,
Apr 16, 2004, 12:28:33 AM4/16/04
to l...@toetsch.at, perl6-i...@perl.org
On Sat, 2004-04-10 at 01:49, Leopold Toetsch wrote:

> >> 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

Leopold Toetsch

unread,
Apr 16, 2004, 3:58:12 AM4/16/04
to Chromatic, perl6-i...@perl.org
Chromatic <chro...@wgz.org> wrote:

> 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

0 new messages