New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
~ in regexes shouldn't cause thrown exceptions #596
Comments
From @moritzRakudo r35221: regex t1 { 'x(ab' !~~ m/<t1>/; The regex match throws an exception because the final ')' isn't found This is tested in t/spec/S05-metachars/tilde.t (which I hope to enhance Cheers, -- |
1 similar comment
From @moritzRakudo r35221: regex t1 { 'x(ab' !~~ m/<t1>/; The regex match throws an exception because the final ')' isn't found This is tested in t/spec/S05-metachars/tilde.t (which I hope to enhance Cheers, -- |
From @masak<masak> rakudo: say '(foo' ~~ / '(' ~ ')' [foo] / |
@coke - Status changed from 'new' to 'open' |
From @masak<masak> as an author of grammars, I still find it annoying and difficult that grammars generally fail, that is, return a failing match -- *unless* you use the `~` combinator, in which case they nqp::die with an exception that can't be properly caught using a CATCH. |
From @pmichaudAfter discussion with jnthn at OSDC.no, here's what we propose: In the regex engine, the default FAILGOAL behavior should be to simply fail/backtrack. This would be the default behavior for (rakudo) Cursor as well. Grammars that wish to have the generate-an-exception behavior can override FAILGOAL to do so. The HLL::Grammar class (in NQP) will do this, meaning that Rakudo's grammar will still inherit/retain the throw-an-exception behavior. Part of our reasoning (which may be faulty) for this approach is that it's relatively easy to override FAILGOAL in a grammar but harder to do so for regexes that aren't in a grammar. In the latter case (regex), it's more likely that you want simple backtracking rather than the "throw an error message", so that should be the default. I propose to clean up the FAILGOAL API in NQP and Rakudo, then update S05 to match. Any objections or reactions would be welcomed. Pm |
From @masakOn Mon May 11 05:26:45 2015, pmichaud wrote:
This sounds very sane. +1 |
From @jnthnOn Tue May 12 06:47:23 2015, masak wrote:
TimToaday++ approved also. I did the changes to implement the new semantics, and unfudged the existing tests for this ticket. |
@jnthn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#62086 (status was 'resolved')
Searchable as RT62086$
The text was updated successfully, but these errors were encountered: