Entomy / Ada-Improvements

Repository of Ada language improvement ideas
GNU General Public License v3.0
4 stars 0 forks source link

Enumeration syntax #7

Open Entomy opened 5 years ago

Entomy commented 5 years ago

Ada does:

type Example is (First, Second, Third);

for Example use (
    First => 1,
    Second => 2,
    Third => 4);

It should be:

default ordered:

enumeration Example is First, Second, Third;

representation specified:

enumeration Example is
    First := 1,
    Second := 2,
    Third := 4;

Rationale: Enumerations are a very useful concept that was made overly cumbersome in Ada. These changes would also greatly simplify other possible changes to enumerations.

Furthermore enum would be fine but enumeration is listed here because of intellisense greatly decreasing necessary keystrokes anyways. So optimizing source for readability was chosen.

Joebeazelman commented 2 years ago

Yes, enumerations should allow specifying their values inline. The := is an assignment, whereas => clarifies it has a different underlying semantics.