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

Make it easier to find out about array and map literals #137

Open
lerno opened this issue Jul 21, 2023 · 1 comment
Open

Make it easier to find out about array and map literals #137

lerno opened this issue Jul 21, 2023 · 1 comment

Comments

@lerno
Copy link

lerno commented Jul 21, 2023

The initial parts of the current overview documentation deals with literals: https://odin-lang.org/docs/overview/#lexical-elements-and-literals

However, this section only mentions characters and numbers. It does not mention array literals, which are only implicitly mentioned here: https://odin-lang.org/docs/overview/#fixed-arrays and given an example here: under a different heading: https://odin-lang.org/docs/overview/#slice-literals. Furthermore, I think it might lack some of the ways one can construct array literals.

For maps the situation is similar: https://odin-lang.org/docs/overview/#maps

And furthermore it is not clear if the map initialization also allows you to initialize nested maps, e.g. a map containing a map of ints.

The literals missing from the first part that I have seen are:

  1. Array literals
  2. Slice literals
  3. Map literals

true, false and nil could also be considered literals and should probably be listed as well.

@hasanyasin
Copy link

hasanyasin commented Jul 30, 2023

Just taking notes here to use as reference when preparing a PR to resolve this. Please add other things you find missing related to literals.

Considering the less formal style and organization of the document, a good solution would be:

  • under the initial literals section that @lerno mentioned, we add a brief note stating that literals for advanced types are explained under their respective sections, possibly with a list of links to each section.
  • then we scan all the advanced type sections and make sure we list each accepted literal format/style for every type.

Ranged fields in array literals certainly deserve a paragraph or two with examples.

Another missing piece that I noticed is that there is no mention of struct field tags under struct literals section. However, there is an example of

`fmt:"..."`

later under built-ins section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants