On Mon, Jun 26, 2023 at 5:31 PM Zach Daniel <zachary.s.dan...@gmail.com> wrote:
> 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. > If the proposal were to only add this matching pattern for structs, then I agree with your suggestion. However, with maps this only supporting atom keys would *practically* result in the indiscriminate use of `Jason.decode(data, keys: :atom)`. I do not think that this would be a net positive for Elixir, even though with JS/TS I *really* like match destructuring like this. -a > > 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 <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/ >>> . >>> >>> 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 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+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 >>> <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+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 > <https://groups.google.com/d/msgid/elixir-lang-core/ljddd6px.121dd855-dcdc-4231-99c7-26f684cf01fd%40we.are.superhuman.com?utm_medium=email&utm_source=footer> > . > -- Austin Ziegler • halosta...@gmail.com • aus...@halostatue.ca http://www.halostatue.ca/ • http://twitter.com/halostatue -- 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/CAJ4ekQuYoYkQSDnkgE_ngDuPdNacZqcDytAVkQunApFtBsjXbA%40mail.gmail.com.