-
-
Notifications
You must be signed in to change notification settings - Fork 16
make matcher optionally more agressive #4
Comments
Actually, I'm thinking of making this even more generic. That is, adding two modes - a strict one and an agressive one. The strict mode would match the original syntax exactly. And the agressive mode would do just the opposite - it would ignore syntax differences that don't change the static meaning of the program. This is a rabbit hole, so I suggest to keep it limited to constant evaluation and the use of redundant Other forms of aggressive folding wold be for Since the agressive mode is a rabbit hole, I think it would be best to make the strict mode the default. While it's true that requiring the strict mode isn't very common, requiring the aggressive mode isn't common either. And the aggressive one is likely to become complex and/or slow. @rogpeppe thoughts? |
Yeah, I've had the same thoughts. |
I completely forgot about making this a syntax flag, like type restrictions. It could definitely be useful for wildcards. However, all these modifiers have one problem - they can't be applied to non-wildcards. For example, I can't say "any number of I can't find any previous mention of |
Oh, that's an excellent point. That means we definitely need a global flag, and that's fine. |
Ah, I'm struggling to come up with a scenario where the pattern has to mix strict and non-strict parts. So this should be enough reason to just go with the global flag - we can always go a different route in the future, if this isn't enough. However, I'm still bothered by how the wildcard modifiers should really be modifiers on all kinds of nodes. That is, type restrictions and "any of" modifiers should be applicable to non-wildcards too. Although I don't know how that could be possible without complicating the syntax to a point where it would no longer resemble Go. |
One possibility for a type restriction might be Which I guess could be applied to wildcard nodes too. Our current I'm having trouble coming up a use case for "any of" that doesn't involve wildcards. Maybe you could elaborate? |
Ah, making I don't think we should make I gave an example of "any of" before, I struggle to come up with a use case that I would have used recently. Maybe we should come back to this once we encounter it. And of course, there's always the agressive matching, but I can't think of a common use case either. |
+1 |
I'm thinking of doing this with a per-expression leading token (like a modifier). So that, in the future, we may use it in only one of the expressions, instead of for all of them. Also means we don't need a flag. Since we said strict mode as default, I'll make |
To clarify, when I said expression above, I meant pattern. Not any Go expression. So the modifier can only be at the top level, |
Nice. |
For now, all it does is allow a nil node to match a _ name, and vice versa. We will add more to it in the future. Updates #4.
Right now, if one uses
"ab"
in an expression to look for,"a"+"b"
won't be matched. We could usego/const
for this.Is there a reason why a user would ever not want this? If so, we could make it optional via the syntax.
The text was updated successfully, but these errors were encountered: