Suppose I have:
int a;
int b;
Are the variables a and b name equivalent (more specifically, since primitive types don’t have type names, can they be considered name equivalent)?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Name (more properly, nominal) equivalence means that the values have the same type as determined by the (fully qualified) name of their type — for instance,
aandbare nominally type equivalent because they both have “int” type. Structural equivalence means that the values are considered to have the same type because their types are structurally equivalent, regardless of the name. Nominal type equivalence implies structural type equivalence since a named type is structurally equivalent to itself. Youraandb, are nominally type equivalent because they have the same type by name (“int”). The claim that “primitive types don’t have type names” is simply false —intis a type name. And there is no difference betweenint a; int b;andint a, b;— both defineaandbwith the same (structurally and by name) type.C’s type system is generally by name … e.g.,
int *andshort*are different types even ifintandshorthave the same representation, andstruct foo { int x; }andstruct bar { int x; }are different types even though they always have the same representation.