odin-lang / odin-lang.org

http://odin-lang.org
19 stars 80 forks source link

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

Open lerno opened 11 months ago

lerno commented 11 months ago

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 commented 11 months ago

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:

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.