Skip to content
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

Implement @tryswitch #132

Merged
merged 3 commits into from
Dec 28, 2021
Merged

Implement @tryswitch #132

merged 3 commits into from
Dec 28, 2021

Conversation

serenity4
Copy link
Contributor

Implements @tryswitch as an extension to @switch where match failures are silent.

As mentioned in #131 we can move this implementation into a 3rd party library, but I think it is also convenient to have it alongside MLStyle.

@codecov
Copy link

codecov bot commented Dec 28, 2021

Codecov Report

Merging #132 (d6b794e) into master (7bf8143) will increase coverage by 0.68%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #132      +/-   ##
==========================================
+ Coverage   81.94%   82.63%   +0.68%     
==========================================
  Files          26       26              
  Lines        1523     1589      +66     
==========================================
+ Hits         1248     1313      +65     
- Misses        275      276       +1     
Impacted Files Coverage Δ
src/MatchImpl.jl 91.78% <85.71%> (-0.04%) ⬇️
src/AbstractPatterns/impl/RedyFlavoured.jl 91.75% <0.00%> (-0.10%) ⬇️
src/MatchCore.jl 5.50% <0.00%> (-0.06%) ⬇️
src/DeprecationUtils.jl 100.00% <0.00%> (ø)
src/StandardPatterns/WhenCases.jl 100.00% <0.00%> (ø)
src/AbstractPatterns/AbstractPatterns.jl 100.00% <0.00%> (ø)
src/AbstractPatterns/CaseMerge.jl 98.52% <0.00%> (+0.14%) ⬆️
src/Pervasives.jl 92.30% <0.00%> (+0.30%) ⬆️
src/Modules/AST.jl 84.78% <0.00%> (+0.33%) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7bf8143...d6b794e. Read the comment docs.

@Roger-luo
Copy link
Collaborator

since the PR is submitted here, maybe just have it in MLStyle? Expronicon is for meta-programming not the general case of pattern matching.

@thautwarm
Copy link
Owner

@Roger-luo A minor issue here is the implementation reuses @switch macro, hence the macro expands twice. Such operation can produce bad error messages when get used extensively.

@thautwarm
Copy link
Owner

I'd merge this now. Changes can be applied later. Thanks @serenity4 !

@thautwarm thautwarm merged commit ebfbeae into thautwarm:master Dec 28, 2021
@serenity4
Copy link
Contributor Author

@Roger-luo A minor issue here is the implementation reuses @switch macro, hence the macro expands twice. Such operation can produce bad error messages when get used extensively.

Ah, then we can just reuse the few lines of code for @switch (gen_switch and init_cfg). I thought reusing @switch would make it cleaner in terms of implementation. What is the problem with error messages? From a few local tests I couldn't see any issues with it.

@serenity4 serenity4 deleted the tryswitch branch July 6, 2022 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants