xls icon indicating copy to clipboard operation
xls copied to clipboard

[enhancement] Auto-numbering enums

Open RobSpringer opened this issue 2 months ago • 1 comments

What's hard to do? (limit 100 words)

I wager most enums go from 0 - N, so it'd be nice if we could write:

enum Foo : u8 {
  A, B, C, D,
}

Current best alternative workaround (limit 100 words)

enum Foo : u8 {
  A = 0,
  B = 1,
  C = 2, 
  D = 3,
}

Your view of the "best case XLS enhancement" (limit 100 words)

An even cooler bonus would be to allow for different auto-numbering ranges, e.g.,

enum Foo : u8 {
  A = 0, B, C,
  F = 100, G, H,
}

the above would be equivalent to:

enum Foo : u8 {
  A = 0,
  B = 1,
  C = 2,
  F = 100,
  G = 101,
  H = 102
}

RobSpringer avatar Oct 27 '25 17:10 RobSpringer

For reference, rust's take on this is: https://doc.rust-lang.org/reference/items/enumerations.html#implicit-discriminants

proppy avatar Oct 28 '25 23:10 proppy