enum E1 : byte {A, B}
table T1 {
e : E1
}enum E1 : byte {A, B, C}
table T1 {
e : E1
}let e3 : E1? = E1(rawValue: 2)
XCTAssert(e3 == nil)Which is kind of ok I guess. If the old client will than save the state again it will erase the fact that e was set to E1.C
In C# the cast will work out of the box without the client losing data. (http://stackoverflow.com/questions/6413804/why-does-casting-int-to-invalid-enum-value-not-throw-exception)
And honestly I am not sure what will happen in another languages.
Is it an issue, Should we have something like UNKNOWN case in every enum definition?
--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
What you describe is a problem with forwards compatibility actually (backwards compatibility is a newer program reading old data, which is usually easier). And yes, this breaks forwards compatibility, but in a mostly benign way.
Generally, in most code bases, enums are things that are expected to grow, meaning you need to deal with unknown values gracefully (either an error or ignore it).
An enum is an integer value (even in Java, we don't use enum classes). Implementations should cast this integer to the enum type. The result for unknown values is thus a value of an enum type for which the current program will not have an enum identifier, thus can't be explicitly tested against (will end up in the "default" of a switch).