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

BUILD and TWEAK

Thread Next
From:
Richard Hainsworth
Date:
July 21, 2020 08:53
Subject:
BUILD and TWEAK
Message ID:
ed8d395a-4013-8946-ca77-fd59a8f01ef9@gmail.com
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 Next


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