Btw, you may want to check out https://andrealeopardi.com/posts/a-story-of-regret-and-retiring-a-library-from-hex/.
> On 26 Jun 2023, at 21:58, Ben Wilson <benwilson...@gmail.com> wrote: > > Hi, > > This has been proposed before. Someone came up with > https://github.com/meyercm/shorter_maps which accomplishes this as a macro. > It might be worth a discussion again at this point but it is worth noting > that this is a proposal that has been on this list before, and so it would > likely be good to address considerations raised there in this new proposal. > > - Ben > > On Monday, June 26, 2023 at 3:36:16 PM UTC-4 torres....@gmail.com > <http://gmail.com/> wrote: >> Hi, >> I'd like to propose a syntax sugar for maps, specially for pattern matching >> and construction. >> # Map construction >> language = :elixir >> %{ language } >> => %{language: :elixir} >> >> # Map pattern match >> map = %{feature: :pattern_match} >> %{ feature } = map >> => %{feature: :pattern_match} >> feature >> => :pattern_match >> >> case %{ key: "some value" } do >> %{key} -> >> key >> _ -> >> nil >> end >> => "some value" >> >> # Map in function args >> defmodule Foo do >> def bar(%{ key }), >> do: key >> end >> >> Foo.bar(%{ key: "some value" }) >> => "some value" >> >> Of course this would be just a syntax sugar. It won't compromise program's >> performance. >> The advantage of that is mainly when pattern matching function, but also >> case and with statements, on maps with some considerable amount of keys. >> >> with %{ key1 } <- %{key1: "value1"}, >> {:ok, %{key2, key3, key4, key5}} <- >> {:ok, %{key2: "value2", key3: "value3", key4: "value4", key5: "value5"}} >> do >> {key1, key2, key3, key4, key5} >> end >> => {"value1", "value2", "value3", "value4", "value5"} >> >> I'd like to know if more people would be interested on that too. > > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elixir-lang-core+unsubscr...@googlegroups.com > <mailto:elixir-lang-core+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/56ed3f2e-c696-4986-9e34-b31b720d49a9n%40googlegroups.com > > <https://groups.google.com/d/msgid/elixir-lang-core/56ed3f2e-c696-4986-9e34-b31b720d49a9n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/6944AF71-417D-412B-9897-B00C3F0A745A%40wojtekmach.pl.