-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Use new OTP28.1 :re.import for regexes #14719
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
Conversation
From the discussion, the correct way to implement this would be to emit an AST code that looks like this:
And, fwiw, we could support the export option in The big question, is where we are going to emit this code, because someone could still do: quote do
Macro.escape(regex)
end And, in the case above, we wouldn't be able to wrap it around import/export. So I'm thinking this is perhaps best implemented in elixir_erl_pass? We see if there is a Regex node with all fields as literals, and then transparently inline it. Although it means we are special casing regexes in the compiler (which I guess it is fine, since we are already special case them in Kernel). |
Oh I see, that makes more sense indeed. This seems much better than importing on
Gotcha.
Probably a weird idea but sharing it anyway. A way to avoid cheating could be to make |
Yes, this would be the logical extension of this approach. We can sit on it though, we don't have to introduce it now. We can validate it with regular expressions and then consider expanding it based on the use cases. :) |
Sth like 79164c8? re: adding the |
Sorry, I am rather thinking about a completely different approach, which would be detecting the Regex in |
Actually, perhaps we don't need to do it on |
Oh I see, this was the missing piece for me since I didn't know which AST should be emitted for |
Please go ahead! I have type system work on my plate at the moment :) |
Closing in favor of #14720 |
This is a PoC to integrate erlang/otp#9976.
I'm not sure about introducing a separate
compile_export
function or always do it incompile
, but given there is a small perf cost for using an exported pattern over a ref one, it might be good to distinguish?If we agree with the approach, will add proper docs.