odin-lang/odin-lang.org

Make it easier to find out about array and map literals

lerno opened this issue · 1 comments

lerno commented

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.

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.