Hi SV, thank you for the proposal. I think a more suitable solution to Elixir would be to not introduce a new syntax to mapsets but, instead, find a mechanism to make the constructions above possible. For example, you mentioned ranges, but they are implemented using macros and a regular operator. All of the logic is encoded in Elixir.
Adding new syntax means adding new special forms, new translations from Elixir to Erlang, and so on. For example, you could achieve most of the proposed behaviour by having a "map_set([keys])" macro, that is valid in patterns and can also create new sets outside of patterns. Similarly, a "is_in_set" guard could be added similar to "is_map_key". The argument against having a map_set/1 macro is that it doesn't feel first-class, like maps or lists. We have discussed potential alternatives to this problem a couple times, and it may be worth revisiting those discussions. For example, there are several data-types, such as URI, Decimal, and MapSet, that are represented using a format that cannot be copied back to Elixir code: iex(1)> MapSet.new([1, 2, 3]) #MapSet<[1, 2, 3]> While they could have a portable representation, such as: %MapSet[1, 2, 3] But the language does not support such mechanism. If we did address this issue though, it would be more generally usable for other types and it could be generic enough to support most of your use cases (except for syntactical updates, which I think is not that important). On Mon, Feb 7, 2022 at 11:33 AM SJ <[email protected]> wrote: > Hi all. > > I have set out a proposal of what these things could potentially look like. > > https://gist.github.com/bdanklin/f4fc015fa90e9b33bb8cb580344e1258 > > I searched for prior work in this area and couldn't find any. > > If it's a welcome feature I'd be happy to work on it given some direction > of where to start. > > Thanks for any feedback. > > Best > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/a73ced4a-5f61-4f40-bbba-8ed2749a3e62n%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/a73ced4a-5f61-4f40-bbba-8ed2749a3e62n%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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KiUzV6NgUJdCY7na4ESych9QB37MUEUX%3DZkm_80VJT%3DA%40mail.gmail.com.
