But we already have ..., !!! and ???. Isn't it what you want?

<AlexDaniel> m: sub foo() { … }; foo
<camelia> rakudo-moar 608e88: OUTPUT: «Stub code executed␤ in sub foo at <tmp>
line 1␤ in block <unit> at <tmp> line 1␤␤Actually thrown at:␤ in block <unit>
at <tmp> line 1␤␤»
<AlexDaniel> m: sub foo() { !!! }; foo
<camelia> rakudo-moar 608e88: OUTPUT: «Stub code executed␤ in sub foo at <tmp>
line 1␤ in block <unit> at <tmp> line 1␤␤»
<AlexDaniel> m: sub foo() { ??? }; foo
<camelia> rakudo-moar 608e88: OUTPUT: «Stub code executed␤ in sub foo at <tmp>
line 1␤»

On 2017-05-29 16:03:29, 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!"] {...}

Reply via email to