Closed lpil closed 3 years ago
Given that atoms are really common in the ecosystem, do you see any downsides for having simpler syntactic support for atoms like Elixir’s :atom
for example?
They're common in the ecosystem but I'm not sure they should be common in Gleam. They're basically strings so a custom type is normally more precise and more safe in Gleam APIs, so much so I'm still not sure about this feature here.
We can always add it later, it is much harder to remove a feature!
Indeed, I forgot about how types map to atoms. So, in general it's much better to depend on defining custom types instead of calling atom.from_string
It would be useful to be able to create other string like literals such as atoms.
One option would be to have the
const
syntax convert a string literal into an atom for use elsewhere in the program. This would work by having const check the annotation, and then converting the string into an atom if the annotation isAtom
We would need to promote
Atom
into the prelude from the stdlib for this.Syntax suggestions
This matches the derive syntax suggested in gleam-lang/gleam#565