3 ms·
Right. Elixir's sigils (https://elixir-lang.org/getting-started/sigils.html https://elixir-lang.org/getting-started/sigils.html) are just a macros in the curren
by derefr 5y ago
Right. Elixir's sigils (https://elixir-lang.org/getting-started/sigils.html https://elixir-lang.org/getting-started/sigils.html) are just a macros in the current namespace of name name pattern sigil_[letter], where writing ~x/foo/ or ~x(foo) etc., evaluates the macro sigil_x("foo") at compile-time.
The JavaScript equivalent with tagged template literals isn't the same, because it isn't a macro, and so the template function has to run at runtime. As such, these are no longer literals (i.e. pure data) per se.
The C++ equivalent is closer, if-and-only-if the user-defined literal operator function call is a constexpr that gets pre-evaluated.