rossvideo / Catena

Other
5 stars 1 forks source link

create a STRUCT_VARIANT constraint #59

Open mejohnnaylor opened 7 months ago

mejohnnaylor commented 7 months ago

motivation - to mark STRUCT_VARIANT parameters that support type changes (to sibling variants) at run-time distinguishable from those that do not.

sketch:

{
  "constraint": {
    "type": "STRUCT_VARIANT_CONSTRAINT";
    "is_final": true if type is final, false if it can be changed at runtime.
  }
}
mejohnnaylor commented 7 months ago

LMK what you think of this approach, JP.

james-peltzer commented 7 months ago

is_final is not very descriptive since it doesn't really say what is final. How about something more along the lines of: variation_immutable

Happy to spitball more options.

mejohnnaylor commented 7 months ago

I was channeling "final" as a C++ / Java keyword / specifier. I think the users of this interface definition will have enough exposure to either / both usages to understand the meaning.

james-peltzer commented 7 months ago

okay - so you're also not going to go for 'static variation'?

mejohnnaylor commented 7 months ago

"mutable_at_runtime": bool // probably provides most clarity (or "runtime_mutable"), and has the benefit of being false (i.e.) safe by default.

mejohnnaylor commented 7 months ago

discussion notes, JP + JRN

mutable_types.

behaviour if a client tries to change the type of a STRUCT_VARIANT, or member of a STRUCT_VARIANT_ARRAY...

if (mutable_types) { make the change status = OK } else { status = FAILED_PRECONDITION }