[erlang-questions] Binary string literal syntax
Loïc Hoguin
essen@REDACTED
Wed Jun 6 15:57:53 CEST 2018
Alternatively, allow making use of Unicode and support the characters «
and » alongside << and >>. This is already what I use when writing code
(using vim's conceal feature) and it makes the source a lot prettier to
read.
Sames goes for the various arrows.
I think another language already does this, was it Ocaml?
On 06/05/2018 07:51 PM, Sean Hinde wrote:
> I’ve been writing a lot of Elixir over the last few months (plus Swift, Java, C) and just came back to Erlang. There are a few things I’ve come to very much like about Elixir I think might be quite useful to bring to Erlang.
>
> The first, and topic of this email, is arguably trivial, but having to surround <<“modern”>> string literals with <<>> is irritating and not getting any less so.
>
> It occurred to me we might usefully steal the sigil notation from Elixir to solve this and add other string literal related syntactic niceties.
>
> My proposal would be to add an alternative notation for binary string literals in Erlang along the lines of:
>
> ~s”Some binary string” mapping to <<"Some binary string”>>
>
> This would open the door to other alternative notations. e.g. Elixir has one for regex friendly strings:
>
> ~r/foo|bar/
>
> String literals containing quotes could also benefit from different delimiter characters e.g.
>
> ~s'{"Name":"Tom","Age":10}’ mapping to <<"{\"Name\":\"Tom\",\"Age\":10}”>>
>
> The Elixir docs cover more options: https://elixir-lang.org/getting-started/sigils.html. There are 8 alternative delimiters, and even user defined sigils and interpolation with #{}
>
> If we didn’t want to go as far as Elixir style sigils we could just use a single prefix char.
>
> LFE uses:
>
> #”Some binary string”
>
> or maybe
>
> ~”Some binary string”
>
> If people here on the list think there is anything useful in this, and we can reach some kind of rough consensus on how far it makes sense to go I will put some effort into an EEP.
>
> Sean
>
> - first post since July 2008. It’s good to be back
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
--
Loïc Hoguin
https://ninenines.eu
More information about the erlang-questions
mailing list