You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, your desired syntax of ~m{ #{...} } will probably never work, as I was unable to make a good enough argument for nested braces in this Elixir issue. Currently, the sigil will be terminated with the first }, which will be found at the end of your interpolation (This is the actual error in your example, but it still wouldn't work, see below). The easy work around is to just use ~m( #{...} ). The harder solution is to succeed where I failed, and convince @josevalim that embedding braces in sigils is worthwhile.
Second: ShortMaps, the project we started with, didn't support interpolation, and when I copied the codebase, I never thought to add it. This is probably the easiest of our three hurdles.
Third, and most difficult to circumnavigate. Consider this simple module:
In case that isn't clear; ~Z is actually receiving different parameters from the compiler. This is a surprise to me, but careful re-reading of the Elixir Sigils documentation proves that is the intended behavior, even if it seems like something that should be left up to the sigil (as I thought it was). I'm not sure I see a great way around this problem while continuing to use Sigils... the best I have is to use the ~m(...)a construction, which I generally disdain.
In the destructure library, the author bypasses sigils, and writes a macro d() to accomplish the map expansions. I don't think I like the paren-omissions and the % inclusion that he uses, but we could add a m() and M() macro to ShorterMaps to accomplish the string interpolation goal, as well as gain back syntax highlighting.
I have a use case in which I have a list of fields names that I would like to interpolate into the ~m and ~M sigils.
Current functionality
Desired functionality
The text was updated successfully, but these errors were encountered: