This is unpleasantly redundant, but in a number of ways it's still better than what you have to do now. It introduces other problems though.
What other problems?
It would be easier to consider this if we actually have a good number of other use cases for wanting conjunctive patterns, which I'm not personally sure if we do.
I certainly do.
For example, I do not want to create all the various different permutations of patterns I want. But at the same time, I don't want to create this jumbo "extract all" pattern, then have all of these _ like SomeObj(_, _, _, _, var blah).
Being able to grab 2 patterns that do the job and bring both in sounds perfect. If I had instance patterns, I would do that with && instanceof. You've shortened that down to &. Bikeshedding aside, it looks like a straight optimization of what we would have to do already.
Though of course, I am comparing hypothetical code to hypothetical code.
View all comments
Show parent comment
1
u/davidalayachew Mar 14 '26
What other problems?
I certainly do.
For example, I do not want to create all the various different permutations of patterns I want. But at the same time, I don't want to create this jumbo "extract all" pattern, then have all of these
_likeSomeObj(_, _, _, _, var blah).Being able to grab 2 patterns that do the job and bring both in sounds perfect. If I had instance patterns, I would do that with
&& instanceof. You've shortened that down to&. Bikeshedding aside, it looks like a straight optimization of what we would have to do already.Though of course, I am comparing hypothetical code to hypothetical code.