Starlark's struct has some features we should port over to the ytt implementation of this data structure. Doing so avoids any surprises that arise from an enterprising user seeing the Starlark struct in use, somewhere, and attempting to mimic such expressions in their ytt templates/programs.
Starlark’s struct:
triggers adding a hint when an attribute is not found by returning an starlark.NoSuchAttrError
implements HasBinary — allowing for + to merge two structs
participates in freezing
also, there are other Starlark features that struct could opt-in on:
HasSetField/HasSetIndex allows unfrozen structs to be mutable (currently, you’d have to decode, convert and encode)
fine point: this depends on implementing freezing so that modifications to Data Values fails fast.
Starlark's struct has some features we should port over to the
ytt
implementation of this data structure. Doing so avoids any surprises that arise from an enterprising user seeing the Starlark struct in use, somewhere, and attempting to mimic such expressions in theirytt
templates/programs.Starlark’s struct:
starlark.NoSuchAttrError
HasBinary
— allowing for+
to merge two structsalso, there are other Starlark features that
struct
could opt-in on:HasSetField
/HasSetIndex
allows unfrozen structs to be mutable (currently, you’d have to decode, convert and encode)