D
Dave Sexton
Hi Dustin,
Ok, so ILASM also prevents the declaration of methods on enums, but does that
change the definition of structure from being "any object that can be
allocated on the stack"?
Admittedly, I have no formal definition to cite. I've inferred the meaning of
the term "structure" from experience using .NET and its use in MSDN
documentation, which I've cited already.
I'm waiting on Chris to supply evidence to the contrary (within the scope of
managed programming, I might add).
--
Dave Sexton
Ok, so ILASM also prevents the declaration of methods on enums, but does that
change the definition of structure from being "any object that can be
allocated on the stack"?
Admittedly, I have no formal definition to cite. I've inferred the meaning of
the term "structure" from experience using .NET and its use in MSDN
documentation, which I've cited already.
I'm waiting on Chris to supply evidence to the contrary (within the scope of
managed programming, I might add).
--
Dave Sexton
Dustin Campbell said:I've been trying to stay away from C# here, and just discuss whether
all value-types are structures (although I have been referring to them
as structs from time to time, which as I said in a related post might
have been a bit misleading - but it's habit). I believe that you can
derive from System.Enum and add methods or implement interfaces in
CIL, so your point doesn't hold true on a framework level (as opposed
to just C#). Please correct me if I'm wrong.
That's incorrect. This will fail to assemble:
.assembly extern mscorlib { auto }
.assembly FruitTest { }
.module FruitTest.exe
.class public auto ansi sealed Fruit
extends [mscorlib]System.Enum
{
.field public specialname int32 __value
.field public static literal valuetype Fruit Banana = int32(1)
.field public static literal valuetype Fruit Apple = int32(2)
.field public static literal valuetype Fruit Orange = int32(3)
.method public int32 GetIndex() cil managed
{
ldfld int32 Fruit::__value
ret
}
}
The error is "error -- Method in enum".
So, clearly, enumerations are *not* structures because they lack all but one
of the features of a structure.
Best Regards,
Dustin Campbell
Developer Express Inc.