develooper Front page | perl.perl6.users | Postings from July 2020

Re: BUILD and TWEAK

Thread Previous | Thread Next
From:
Vadim Belman
Date:
July 21, 2020 20:48
Subject:
Re: BUILD and TWEAK
Message ID:
4FA829C1-4D4D-4FA6-AACE-A1177D6903E0@lflat.org

Oh, and the thing I forgot to mention: contrary to BUILD and TWEAK, DESTROY is invoked by underlying backend VM. I.e. by MoarVM, or JVM, or JS because only the VM knows when exactly an object cease to exists.

Best regards,
Vadim Belman

> On Jul 21, 2020, at 4:53 AM, Richard Hainsworth <rnhainsworth@gmail.com> wrote:
> 
> Trying to update the documentation on submethod TWEAK - there is nothing.
> 
> But the documentation should be accurate and not confusing. So some questions:
> 
> In a loop or program, things like BUILD or LEAVE or FIRST are called 'phasers'.
> 
> By analogy, during the 'build' process of instantiating an object from a class, two 'submethod's can be called, viz.
> 
> submethod BUILD and submethod TWEAK.
> 
> 1) Should these submethods be considered 'phasers' to be consistent with other BUILD, LEAVE etc usages?
> 
> 2) What actually calls these submethods?
> 
> The documentation says 'bless' indirectly calls submethod BUILD. But the documentation seems to indicate that 'bless' is not needed to create an object.
> 
> So what calls the submethods?
> 
> 3) Is it correct to say that TWEAK can access all the attributes of the object?
> 
> 4) How to describe the way the TWEAK of a subclass accesses attributes in the parent?
> 
> eg
> 
> class A { has $.thing }
> 
> class B is A { submethod TWEAK { #do something to $.thing in A } }
> 

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About