6.4 Type Names, Declarations and Recursive Types

Many languages like C allow user defined named complex types. In C, this is specified via typedef statement. You must have seen and used several examples of this kind of named types.

How do we check equivalence if named types are used?

Two approaches are possible:

Named equivalence: Treat named types as simple types and just check that two program components have the same name.

Structural equivalence: Replace the named type by their definitions (which may be a definition tree) and recursively check those trees.

For example, let us define two user-defined data types:

typedef float * series;
typedef float * sequence;

These two data types series sequence are different for named equivalence viewpoint, ...

Get Compilers: Principles and Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.