Skip to content

Conversation

@sabiwara
Copy link
Contributor

@sabiwara sabiwara commented Jun 7, 2025

Close #14497

This approach might be overkill, maybe making it regex aware is better here. I'm not sure.

TT =
[if
is_reference(V) ->
[case extract_value_ref(V) of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of extracting value, could we perhaps do a do_quote_map_value that checks for references, tuples, and otherwise just fallbacks to do_quote, returning either {ok, Quoted} or {error, Ref}?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josevalim is it what you meant? 30ee6fd

I personally prefer the previous version since it's slightly more DRY and needs less params to be passed around, but no strong opinion.

I have another idea too, will try to push as an alternative proposal and let you chose 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda like this one 26f3584 readability-wise, even if line-wise it's slightly longer.
But I liked the initial version too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josevalim is it what you meant? 30ee6fd

The idea is that you would already do the quoting as you traverse the tuple. :) This way it would be easier to traverse other data structures (even lists) without additional overhead. Although it does come with some duplication.

It is your call though! Pick whatever you prefer and ship it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean.
But yeah, it indeed would cause duplication and might not even be such a win perf-wise, even if we do it in one pass:

  • current version: just walks the structure without creating structures and do a couple of comparisons, should be quite fast
  • suggested version: would need to create OK tuples (and more complexity / duplication)

It is your call though! Pick whatever you prefer and ship it!

Will merge the latest version then!
Should I backport or is there no more 1.18 planned?

@sabiwara sabiwara merged commit 84d8066 into elixir-lang:main Jun 7, 2025
13 checks passed
@sabiwara sabiwara deleted the escape-regex branch June 7, 2025 12:56
sabiwara added a commit to sabiwara/elixir that referenced this pull request Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

List of regex in module attributes do not emit a warning in Elixir 1.19

2 participants