RE: Perl 6 Object Construction - General Advice

2017-10-05 Thread Mark Devine
Paulssen [mailto:t...@wakelift.de] Sent: Sunday, October 1, 2017 16:56 To: perl6-users@perl.org Subject: Re: Perl 6 Object Construction - General Advice I wrote another more in-depth (but potentially less useful to you) mail about this further down the thread, but I thought it'd be good

RE: Perl 6 Object Construction - General Advice

2017-10-05 Thread Mark Devine
ssage- From: Timo Paulssen [mailto:t...@wakelift.de] Sent: Thursday, October 5, 2017 13:56 To: Mark Devine ; 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,

Re: Perl 6 Object Construction - General Advice

2017-10-05 Thread Timo Paulssen
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 th

Re: Perl 6 Object Construction - General Advice

2017-10-01 Thread Daniel Schröer
Am 30.09.2017 19:34 schrieb "Mark Devine" : My most common OC case: initialize attributes at OC time from external input that will be parsed with grammars &/| scrubbed with elaborate conditional tests. Just a shot in the dark without fully understanding the above: maybe your difficulties indicat

Re: Perl 6 Object Construction - General Advice

2017-10-01 Thread Brandon Allbery
On Sun, Oct 1, 2017 at 4:56 PM, Timo Paulssen wrote: > *method new* is useful only if you want to take positional parameters for > the .new — the default new you get from *Mu* only accepts named arguments > and passes them on as-is to *self.bless*. They then get passed to every > *BUILD* and *TWE

Re: Perl 6 Object Construction - General Advice

2017-10-01 Thread Timo Paulssen
I wrote another more in-depth (but potentially less useful to you) mail about this further down the thread, but I thought it'd be good to point this out near the top: I think the /self.bless(|%args)!initialize/ idiom is a work-around for /submethod TWEAK/ not yet existing when this code was writte

Re: Perl 6 Object Construction - General Advice

2017-10-01 Thread Timo Paulssen
Here's the internal details of the guts: BUILDALL has so far been sort of an interpreter for something called the "buildplan". When a class gets composed (usually what happens immediately when the parser sees the closing } of the class definition) all attributes are considered along with their def

Re: Perl 6 Object Construction - General Advice

2017-10-01 Thread Brandon Allbery
On Sun, Oct 1, 2017 at 1:02 PM, yary wrote: > > I hadn't heard of TWEAK, thought that BUILD was for setting private > attributes and other tasks the object runs to build itself. > IIRC having BUILD overrides default values, so if you want to have those and still adjust things at object initializa

Re: Perl 6 Object Construction - General Advice

2017-10-01 Thread yary
I barely write any p6 but my impression was to avoid bless, and stick with using named arguments for object creation. Using positional parameters forces creating a "method new ..." I hadn't heard of TWEAK, thought that BUILD was for setting private attributes and other tasks the object runs to bui

Re: Perl 6 Object Construction - General Advice

2017-09-30 Thread Brian Duggan
On Saturday, September 30, Mark Devine wrote: > My most common OC case: initialize attributes at OC time from external > input that will be parsed with grammars &/| scrubbed with elaborate > conditional tests. I like to use assignment for simple things and TWEAK for complicated things -- cl

Perl 6 Object Construction - General Advice

2017-09-30 Thread Mark Devine
Perl 6, I am preparing to write several classes for some Perl 6 apps I intend to craft in support of a prominent backup suite. In looking at the documentation & some of the modules published in the Perl 6 ecosystem, I’m not quite sure that I can identify the best idiomatic object construction