develooper Front page | perl.perl6.internals | Postings from February 2001

Re: PDD 2, vtables

Thread Previous | Thread Next
Dan Sugalski
February 18, 2001 23:29
Re: PDD 2, vtables
Message ID:
At 02:50 AM 2/19/2001 +0000, Simon Cozens wrote:
>On Sun, Feb 18, 2001 at 09:34:46PM -0500, Dan Sugalski wrote:
> > At 01:13 AM 2/19/2001 +0000, Alan Burlison wrote:
> > >Dan Sugalski wrote:
> > >
> > > > Grab one via a utility function. getPMC() or something of the sort.
> > >
> > >newPMC() ? ;-)
> >
> > Works for me.
>Slight that-sucks alert: So, if I have to get a new PMC of class X (which is
>something that's going to have to happen often) I call
>     X->vtbl->new(newPMC())
>     X->vtbl->morph(newPMC(),X);

X->vtbl->new. (Whether you snag a new PMC with newPMC or get handed a 
scratch one by the interpreter depends on circumstance) Morph is used for 
active variables, while new can assume that the PMC it was handed is dead.

I was originally thinking that new should handle the case where the PMC it 
was handed might need cleanup, but at this point I think that's a bad 
thing--it forces important code out too many places, and if we want at 
least semi-determinate cleanup we ought be doing it someplace else anyway.


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai                         have teddy bears and even
                                      teddy bears get drunk

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About