Re: [perl #131398] Feature Request: trait for unimplemented subs/methods
That is so easy for a programmer to implement; I have an "nyi" subroutine/function in the my skeleton scripts for both Perl 5 and Bash. Is it worth cluttering the language?
Re: [perl #131398] Feature Request: trait for unimplemented subs/methods
As already mentioned, we have three such stubbers already. You can even put a partial/incomplete implementation after them: just terminate the ... or w/e with a semicolon. What none of them will do for you is allow a syntactically incorrect body. But the proposed feature *also* will not allow that; you'd have to do it as a slang to get that, and even then I suspect you will find error recovery / parser resynchronization to be nontrivial. On Tue, May 30, 2017 at 10:21 AM, Parrot Raiser <1parr...@gmail.com> wrote: > That is so easy for a programmer to implement; I have an "nyi" > subroutine/function in the my skeleton scripts for both Perl 5 and > Bash. Is it worth cluttering the language? > -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
Re: [perl #131398] Feature Request: trait for unimplemented subs/methods
As already mentioned, we have three such stubbers already. You can even put a partial/incomplete implementation after them: just terminate the ... or w/e with a semicolon. What none of them will do for you is allow a syntactically incorrect body. But the proposed feature *also* will not allow that; you'd have to do it as a slang to get that, and even then I suspect you will find error recovery / parser resynchronization to be nontrivial. On Tue, May 30, 2017 at 10:21 AM, Parrot Raiser <1parr...@gmail.com> wrote: > That is so easy for a programmer to implement; I have an "nyi" > subroutine/function in the my skeleton scripts for both Perl 5 and > Bash. Is it worth cluttering the language? > -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
Re: [perl #131398] Feature Request: trait for unimplemented subs/methods
That is so easy for a programmer to implement; I have an "nyi" subroutine/function in the my skeleton scripts for both Perl 5 and Bash. Is it worth cluttering the language?
[perl #131398] Feature Request: trait for unimplemented subs/methods
But we already have ..., !!! and ???. Isn't it what you want? m: sub foo() { … }; foo rakudo-moar 608e88: OUTPUT: «Stub code executed in sub foo at line 1 in block at line 1Actually thrown at: in block at line 1» m: sub foo() { !!! }; foo rakudo-moar 608e88: OUTPUT: «Stub code executed in sub foo at line 1 in block at line 1» m: sub foo() { ??? }; foo rakudo-moar 608e88: OUTPUT: «Stub code executed in sub foo at 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!"] {...}
[perl #131398] Feature Request: trait for unimplemented subs/methods
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` Perhaps, you could publish it as a module: https://docs.perl6.org/language/modules
[perl #131398] Feature Request: trait for unimplemented subs/methods
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` Perhaps, you could publish it as a module: https://docs.perl6.org/language/modules
[perl #131398] Feature Request: trait for unimplemented subs/methods
# New Ticket Created by Benjamin Goldberg # Please include the string: [perl #131398] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=131398 > 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!"] {...}