Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erlang: Alias quoted-atom and atom to symbol #3382

Closed
wants to merge 1 commit into from

Conversation

hoonweiting
Copy link
Contributor

In Erlang,

An atom is a literal, a constant with name.

which matches the standard token symbol. This PR adds symbol as an alias to quoted-atom and atom.

@github-actions
Copy link

JS File Size Changes (gzipped)

A total of 1 files have changed, with a combined diff of +16 B (+3.5%).

file master pull size diff % diff
components/prism-erlang.min.js 452 B 468 B +16 B +3.5%

Generated by 🚫 dangerJS against e5a21f1

@RunDevelopment
Copy link
Member

I don't think this is a good idea. While atoms are indeed close to symbols, they are also very common, like, almost everything is a symbol kinda common. If we added this alias, then all symbols would get a color which would leave no character un-highlighted. And if everything is highlighted, nothing is. Example.

Also, aren't atoms closer to identifiers when compared to a C-like language?

@hoonweiting
Copy link
Contributor Author

@RunDevelopment That's a really good point, and I agree with where you're coming from!

I suppose then it depends on whether it is more important to guarantee the token types, or to maintain a reasonable amount of highlighting. I think the latter would be preferable for users, so I guess I would be in favour of closing this PR.

Also, aren't atoms closer to identifiers when compared to a C-like language?

Without having studied computer science, I don't think I can answer this satisfactorily 😅 I'll give it a go anyway, and I'll be happy to be corrected.
I gave it a quick google, and here's the first sentence of the C Identifiers article in Microsoft docs:

"Identifiers" or "symbols" are the names you supply for variables, types, functions, and labels in your program.

Here's the first two sentences from Erlang's Types Specifications:

Types describe sets of Erlang terms. Types consist of, and are built from, a set of predefined types, for example, integer(), atom(), and pid().

From only these two sources, it appears to me that identifiers in C aren't the same as atoms in Erlang. I would think identifiers encompass atoms and other types. On the other hand, a symbol is a primitive data type found in some languages (which can be used as an identifier), so I would also think that identifiers can encompass symbols (this is getting confusing!).

However, I acknowledge that you mentioned C-like languages and not specifically C, so I'm not sure if I've made a very accurate assessment here.

@RunDevelopment
Copy link
Member

Oh, I completely overlooked that atoms are a type of data in Erlang. I should have looked at the title of the page you linked... My bad. You're right that atoms are like the symbols of many functional languages, and that they fit the definition of symbol we use for standard tokens.

However, I would still favor closing this PR, so we don't overload the highlighting. Sorry.


Also, you can still tick Erlang off the list in #3170. After all, using only non-standard tokens is perfectly compliant with our definition of standard token :)

@hoonweiting
Copy link
Contributor Author

Thank you for the discussion @RunDevelopment! :)

@hoonweiting hoonweiting deleted the 3170-erlang-atom branch March 13, 2022 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants