T
Tom Baxter
Hi All,
I was hoping someone could clarify something I read in the C# Language Spec
regarding "Definite Assignment" of structs. This is a very subtle point.
I am referring to ECMA-334, section 12.3:
It seems like the two bullet points above can result in circular logic
depending on one's interpretation. If you interpret these points as:
* An instance variable is considered definitely assigned if and only if
its containing struct-type variable is considered definitely assigned.
* A struct-type variable is considered definitely assigned if and only
if each of its instance variable is considered definitely assigned.
then we have a deadlock situation because a struct's instance members are
definitely assigned exactly when the struct variable is definitely assigned.
But the struct variable is definitely assigned exactly when all its instance
variables are definitely assigned. It's the Chicken and the Egg Problem.
Now, I realize the meaning of "if" is much different from that of "if and
only if" but I'm wondering about the intent of the passages. Did the authors
really mean "if and only if"? I doubt it. I suspect the authors meant "if",
as it's written.
(I told you it was subtle). So, if the authors of the spec meant "if", as it
was written, then there must be some way for the instance variables of a
struct variable to be definitely assigned other than the struct variable
itself being definitely assigned. Similarly, there must be some way for the
struct variable to be definitely assigned other than having all its instance
variables definitely assigned.
So (whew!), assuming the authors of the spec meant to say "if" and not "if
and only if", my question is, how can the instance variables of a struct be
definitely assigned without the containing struct variable being definitely
assigned? And, how can a struct instance variable be definitely assigned
without all of its instance variables being definitely assigned?
If you tell me there is a mutual dependency between the struct instance
members and the struct variable itself, then you are telling me we have a
Chicken and Egg Problem.
Anyone still reading??? Thanks!
I was hoping someone could clarify something I read in the C# Language Spec
regarding "Definite Assignment" of structs. This is a very subtle point.
I am referring to ECMA-334, section 12.3:
The definite assignment states of instance variable of a struct-type
variable are tracked individually as well as collectively. In addition to
the rules above, the following rules apply to struct-type variables and
their instance variables:
* An instance variable is considered definitely assigned if its
containing struct-type variable is considered definitely assigned.
* A struct-type variable is considered definitely assigned if each of
its instance variable is considered definitely assigned.
It seems like the two bullet points above can result in circular logic
depending on one's interpretation. If you interpret these points as:
* An instance variable is considered definitely assigned if and only if
its containing struct-type variable is considered definitely assigned.
* A struct-type variable is considered definitely assigned if and only
if each of its instance variable is considered definitely assigned.
then we have a deadlock situation because a struct's instance members are
definitely assigned exactly when the struct variable is definitely assigned.
But the struct variable is definitely assigned exactly when all its instance
variables are definitely assigned. It's the Chicken and the Egg Problem.
Now, I realize the meaning of "if" is much different from that of "if and
only if" but I'm wondering about the intent of the passages. Did the authors
really mean "if and only if"? I doubt it. I suspect the authors meant "if",
as it's written.
(I told you it was subtle). So, if the authors of the spec meant "if", as it
was written, then there must be some way for the instance variables of a
struct variable to be definitely assigned other than the struct variable
itself being definitely assigned. Similarly, there must be some way for the
struct variable to be definitely assigned other than having all its instance
variables definitely assigned.
So (whew!), assuming the authors of the spec meant to say "if" and not "if
and only if", my question is, how can the instance variables of a struct be
definitely assigned without the containing struct variable being definitely
assigned? And, how can a struct instance variable be definitely assigned
without all of its instance variables being definitely assigned?
If you tell me there is a mutual dependency between the struct instance
members and the struct variable itself, then you are telling me we have a
Chicken and Egg Problem.
Anyone still reading??? Thanks!