On 18 May 2024 17:13:49 BST, Larry Garfield <la...@garfieldtech.com> wrote:
>However, that breaks down with readonly properties, which are not allowed to
>have a sentinel. Uninitialized is their sentinel, for better or worse.
Sorry, I don't understand this statement at all. A readonly property can be set
to PatchState::KeepCurrentValue just like any other. If the intention is that
that state will be overwritten with an actual value later, then it's not a
readonly property.
I guess you have some different scenario in mind?
> And as I noted earlier in the thread, when writing a serializer or other
> dynamic systems (an ORM probably would have the same issue), you really need
> to be able to differentiate between null and uninitialized. Even if you
> think the uninitialized value is a sign of an error, it's coming from code
> you don't control so you have to be able to handle it somehow.
If a property is uninitialized, the object is in an invalid state, and
attempting to read that property gives an error. That's by design, and as it
should be.
Are you saying that you want to be able to detect the error before it happens?
Why?
Rowan Tommins
[IMSoP]