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