josevalim

josevalim

Creator of Elixir

Hi everyone,

We are considering deprecating 'charlists' in Elixir in favor of ~c"charlist". In many languages, 'foobar' is equivalent to "foobar", that’s not the case in Elixir and we believe it leads to confusion. If we were to deprecate this functionality, users would get a warning/error upfront about the usage of single-quotes.

The first step in this journey is to change the formatter to rewrite 'charlist' into ~c"charlist". This will basically make the migration painless for most developers.

With this in mind, @sabiwara has submitted an awesome PR that implements this change in the Elixir codebase. Perhaps, more importantly, he has also simulated PRs to important projects to access the impact of this change. Here they are:

As you can see, the changes are minimal to most projects, including postgrex and mint which integrate with OTP libraries. So from a compatibility point of view, this change is relatively straight-forward.

However, should we go ahead with this change? There would be two reasons for such:

  1. If single quotes raised/warned in the future, would that lead to better learning and user experience?

  2. If [97, 98, 99] prints as ~c"abc" in IEx instead of 'abc', is that more, less, or equally confusing? (let’s assume for now that we will either print one or the other, in order to avoid side-tracking the discussion)

Thoughts are welcome!

Showing Posts 1 to 10

olivermt

olivermt

A thousand times yes, also for noobs trying to speak to erlang libs.

greven

greven

Think this would be a great change for newcomers to the language.
Even though it’s a matter of read the docs it is not consistent with other languages like you said, there is a reason for that but at the same time expected behaviour is good. :slight_smile:

Thumbs up from me.

Eiji

Eiji

Amazing! :heart:

Definitely!

Personally I would like to vote for ~c(abc) instead. This would make many beginners think that ~c is “some kind of function”, so significant % of those should take a look at Kernel documentation at start before asking on forum/slack etc. sigil_c documentation would be then a “core/starting point of understanding the charlists”.

I believe we need to enhance said sigil_c documentation a lot. Even if it would not describes charlists in this @doc it still should point to a separate guide describing “what and why” is it.

Sebb

Sebb

:+1:

can we then do

>>> 'someone once said: "Hello, World!" - and now we are stuck with it.'
'someone once said: "Hello, World!" - and now we are stuck with it.'

?

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

I can count on one hand the number of times when I wanted a list of printable ints to be shown as a charlist in the ~7 years I’ve been doing Elixir. Also in that time I’ve answered why it does that countless times to new people and in not one of those cases were they interacting with Erlang and needed it to be printed as text. I think the time has come to legitimately question whether this should still be the default given how easy it is to opt in to the behavior.

Love the change.

21
Post #6
fuelen

fuelen

  1. I think it is equally confusing. We’ll simply achieve changing of wording a bit in topics from newcomers, so instead of

why [97, 98, 99] prints ‘abc’?

we’ll have

why [97, 98, 99] prints ~c"abc"?

In order to avoid confusion at all, the list of integers should be printed as list of integers. In general, I don’t care. I don’t interact with charlists often.

dimitarvp

dimitarvp

I think we should start with IEx.configure(inspect: [charlists: :as_lists]) being the default (as @fuelen seems to be suggesting as well).

I vote for the sigil syntax as well – ~c"abc" and ~c(abc) should be identical, right?

I believe people carry implicit assumptions with them from other tech and that has been visible by the frankly infinite number of times people have come to the forum to ask about why does [97, 98, 99] show 'abc' in iex. So we should piggy-back on those assumptions and have the sigil syntax moving forward.

I love the idea.

sergio

sergio

  1. The 'foobar' != "foobar" bit me quite a bit when I was learning Elixir. Being explicit about it will be a nice change for newcomers to the language.

  2. Having [97, 98, 99] output to terminal also confused the hell out of me many many times. Seeing ~c"abc" in the terminal will be so much better for me and instantly tell me what I’m seeing.

I see it as a win/win for newcomers and veterans alike. Fantastic change @josevalim

ityonemo

ityonemo

If I’m not mistaken you could also do ~c'abc' for any (possibly imaginary) person that insists on a head nod to the past. But I think the question is a presentational one and ~c(abc) flags stronger in a beginner’s mind that “I might not have done something wrong”, though I do think the best solution is to just do charlists as the number lists. Also very much for prohibiting the use of single quotes (except in sigils) as an error moving forward, though a transitional deprecation warning is probably a good idea

joey_the_snake

joey_the_snake

It’s a good thing for newcomers who are using charlists by mistake when they don’t want to.

If you aren’t new and want to use charlists it seems slightly more annoying but not the biggest deal.

Where Next? Top

Trending in Proposals Top

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews