Re: [elixir-core:12051] [Proposal] Memoize sigil_r on OTP 28

2025-03-29 Thread José Valim
The memoization will only be useful if we either do variable hoisting, which are inherently limited to the current function, or we store it in persistent term. The former will require meaningful changes in the compiler and the latter may have runtime impact. Instead, we are discussing adding the o

[elixir-core:12051] [Proposal] Memoize sigil_r on OTP 28

2025-03-29 Thread Kip
TLDR; Memoize (bind to a variable) the result of `Regex.compile!/2` on OTP 28 so that it is only compiled once. Background Since in OTP 28 it's not possible to unquote a regex (~r//) into code, the implementation of sigil_r on OTP 28 has to compile the regex at runtime. In code which itera