I think the proposed syntax adds value and should be implemented as part of the core Elixir syntax. I also think it should not be considered for string keys, only for atom keys.
Here is a really contrived example: `%Struct{some_xy1_stup4d_8345324_name: some_xy1_stup4d_8354324_name} = value` `%Struct{some_xy1_stup4d_8345324_name} = value` Those code snippets do the same thing! Actually, that was a trick, they *don't* do the same thing, if you look closely. If this syntax was adopted more widely, I would be able to tell that, seeing syntax like the second one, the key and variable names are exactly the same. Seeing syntax like the first would likely imply to me that I should look closely as some keys may have been mapped to differently named variables. On Mon, Jun 26, 2023 at 5:18 PM, Kurtis Rainbolt-Greene < kurtis@rainbolt-greene.online > wrote: > > One of the coolest value adds of a thing like babel was that literally > anyone and everyone could take an afternoon to understand the plugin > system and write an experiment for the language and ship it to anyone and > everyone to try out. Because of the design if you wanted to remove > yourself from the experimental syntax you'd just compile one last time and > overwrite the experimental syntax with the regular raw syntax. > > On Mon, Jun 26, 2023 at 2:12 PM Wojtek Mach < wojtek@ wojtekmach. pl ( > woj...@wojtekmach.pl ) > wrote: > > >> Btw, you may want to check out https:/ / andrealeopardi. com/ posts/ >> a-story-of-regret-and-retiring-a-library-from-hex/ >> ( >> https://andrealeopardi.com/posts/a-story-of-regret-and-retiring-a-library-from-hex/ >> ). >> >> >>> On 26 Jun 2023, at 21:58, Ben Wilson < benwilson512@ gmail. com ( >>> benwilson...@gmail.com ) > wrote: >>> >>> Hi, >>> >>> >>> This has been proposed before. Someone came up with https:/ / github. com/ >>> meyercm/ shorter_maps ( 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 ( http://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+unsubscribe@ googlegroups. com ( >>> 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+unsubscribe@ googlegroups. com ( >> 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 ( >> https://groups.google.com/d/msgid/elixir-lang-core/6944AF71-417D-412B-9897-B00C3F0A745A%40wojtekmach.pl?utm_medium=email&utm_source=footer >> ). >> > > > > > > -- > Kurtis Rainbolt-Greene, > Software Developer & Founder of Difference Engineers > 202-643-2263 > > > > > > -- > 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+unsubscribe@ googlegroups. com ( > elixir-lang-core+unsubscr...@googlegroups.com ). > To view this discussion on the web visit https:/ / groups. google. com/ d/ > msgid/ elixir-lang-core/ > CAMhJPGgZjTQcfX4Hy%2BttQEkHhXPNLsueTNE3ijVjcQb6Rjx-9Q%40mail. > gmail. com ( > https://groups.google.com/d/msgid/elixir-lang-core/CAMhJPGgZjTQcfX4Hy%2BttQEkHhXPNLsueTNE3ijVjcQb6Rjx-9Q%40mail.gmail.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/ljddd6px.121dd855-dcdc-4231-99c7-26f684cf01fd%40we.are.superhuman.com.