The issue is that sigils do not work on all cases, such as MapSets, because
sigil terminators would easily get mixed up with the actual Elixir syntax.
So they work for things that have reasonable textual representations
(Dates, URIs and Decimal being good examples).

Let's say we had multi letter sigils and the proposed syntax above (I am
not saying we should, it is just to understand the differences). A Date as
multi-letter sigil could be:

~Date[2022-02-07]

In the syntax from my previous email, it would be:

%Date[2022, 02, 07]

Or:

%Date["2022-02-07"]

So one is textual and the other is structural. The sigil one is unlikely to
help with pattern matching though.

On Mon, Feb 7, 2022 at 2:13 PM Adam Lancaster <a...@a-corp.co.uk> wrote:

> >  While they could have a portable representation, such as ...
>
> Another good portable representation would be a sigil, if we could have
> multi character sigils.
>
> Best
>
> Adam
>
> On 7 Feb 2022, at 13:10, José Valim <jose.va...@dashbit.co> wrote:
>
> 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 <hellobenjamindank...@gmail.com> 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 elixir-lang-core+unsubscr...@googlegroups.com.
>> 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 elixir-lang-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KiUzV6NgUJdCY7na4ESych9QB37MUEUX%3DZkm_80VJT%3DA%40mail.gmail.com
> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KiUzV6NgUJdCY7na4ESych9QB37MUEUX%3DZkm_80VJT%3DA%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/136EEBF3-585A-4EE6-86B0-DD8F7DCD9C77%40a-corp.co.uk
> <https://groups.google.com/d/msgid/elixir-lang-core/136EEBF3-585A-4EE6-86B0-DD8F7DCD9C77%40a-corp.co.uk?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/CAGnRm4LT2Omdd5ftXKDETg3cGjQyFmpa9f6a6LTjg-PSgjH-yQ%40mail.gmail.com.

Reply via email to