On Mon, 29 May 2017 16:03:29 -0700, ben-goldb...@hotmail.com wrote: > There should be a trait, called either nyi or unimplemented (choose your > favorite name and capitalization) which changes the subroutine or method > it's applied to so that, when it's called, it dies or fails with an X::NYI > exception. > > Alternatively, a slightly more generic solution might be more useful: > > role AutoDie[$class, $message?] { > method CALL-ME(*@_, *%_)) { > die $class.new: $message // |(); > } > }; > role AutoFail[$class, $message?] { > method CALL-ME(*@_, *%_) { > fail $class.new: $message // |(); > } > } > > sub foo does AutoFail[X::NYI, "Sorry, we haven't gotten to foo yet!"] {...}
Thank you for the suggestion. However, I don't believe there's any serious demand for this feature, to justify it being included in core. In fact, `does AutoFail[X::NYI, "Sorry, we haven't gotten to foo yet!"] ` is 1 MORE characters to type than `die X::NYI.new: :feature<Sorry, we haven't gotten to foo yet!>` Perhaps, you could publish it as a module: https://docs.perl6.org/language/modules