Skip Menu |

This queue is for tickets about the Class-Std CPAN distribution.

Report information
The Basics
Id: 15300
Status: resolved
Priority: 0/
Queue: Class-Std

People
Owner: Nobody in particular
Requestors: darren [...] DarrenDuncan.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.0.4
Fixed in: (no value)



Subject: make BUILD more like perl 6, applying init_arg and default before calling it
My impression of Class::Std is that it should be helping us develop in Perl 5 more like would be normal in Perl 6. However, in regards to the BUILD submethod, it does some things in the reverse order to how Perl 6 would do it, in my understanding of the spec. You specify the equivalent of 'init_arg' and 'default' in Perl 6 like this: submethod BUILD (+@:foo, +$:bar = 42, *%other_args) { ... } The stated semantics are that the object's @:foo and $:bar properties are set to corresponding named arguments, and the latter to 42 if there isn't such an arg, prior to the main body of BUILD being executed, and so the new values of those properties can be seen, and if necessary changed, or used, by BUILD. Please update Class::Std's new() to apply any init_arg and 'default' values prior to calling BUILD, so that code in BUILD can then be written in the same way as in Perl 6. You can still do your error reporting of bad input values after BUILD as you do now. I expect that this change should be backwards compatible since BUILD code written towards the old behaviour should still continue to work unchanged, as it would have ignored any pre-existing object attribute values. Thank you. -- Darren Duncan
Date: Sun, 30 Oct 2005 22:12:29 -0500
To: bug-Class-Std [...] rt.cpan.org
Subject: Re: [cpan #15300] make BUILD more like perl 6, applying init_arg and default before calling it
From: Damian Conway <thoughtstream [...] gmail.com>
RT-Send-Cc:
The next version will have both BUILD() and START() initializers. BUILD's happen before defaults are filled, START's happen after. You get to choose your initialization semantics by choosing which you use. Damian