clanguage-designtype-equivalence

Why did the language designers of C do type equivalance like this?


I'm learning C and I'm reading about type equivalence.

I'm curious, does anyone have an opinion why they used structural equivalence for arrays and pointers but they used declaration equivalence for structs and unions?

Why the disparity there? What is the benefit of doing declaration equivalence with structs/unions and structural equivalence for everything else?


Solution

  • I'm sure others will present C specific information, but I'll mention that type-equivalence is one of the classic main problems in programming languages theory. Determining whether two types are actually equivalent is a much trickier problem than it may seem.

    For example, here are some overview slides from an academic course just to give you a taste of the headache.