Timo,

Oops.  You're right.  (I was unconditionally sending an argument in my test 
that zeroed it out the attribute that I was watching -- doh!)  Now I can 
confirm that TWEAK is the logical place to further initialize attributes.

I now see the light!

Thanks,

Mark


-----Original Message-----
From: Timo Paulssen [mailto:t...@wakelift.de] 
Sent: Thursday, October 5, 2017 13:56
To: Mark Devine <m...@markdevine.com>; perl6-users@perl.org
Subject: Re: Perl 6 Object Construction - General Advice

The main difference between BUILD and TWEAK is that BUILD will replace all 
default and requiredness handling, while TWEAK keeps it intact.
TWEAK gets run after these aspects had their turn, so if you have an "is 
required" attribute that doesn't get a value passed, the BUILDALL process will 
throw the corresponding exception before TWEAK even gets invoked.

Don't forget that with the assignment syntax for attribute defaults you're 
allowed to do calculations, too! You can even refer to other attributes in 
there, as long as you use the $!foo syntax.

hope that helps
  - Timo

Reply via email to