anderson's equivalence method

A

aarklon

Hi folks,

I was reading narain gehani's book C an advanced introduction

in page no: 51 it is given as follows

anderson suggest that programmers use the following approximate
equivalences with ALGOL like or pascal like declarations and
definitions to help understand and write C declarations and
definitions
(intermediate forms of declarations and definitions are used to help
to determine the equivalences)

when converting a pascal like declaration/definition to a
C declaration/definition or vice versa; *(dereferencing operator)
has a lower precedence than operators [] and ()

EQTO means equivalent to

EX:- int *(*(*x)[6])();
an equivalent pascal like definition is constructed as follows

*(*(*x)[6])() : int

EQTO ( *(*x)[6])() : pointer to int

EQTO (*(*x)[6]) : function returning pointer to int

EQTO *(*x)[6] : function returning pointer to int

EQTO (*x)[6] : pointer to function returning pointer to int

EQTO (*x) : array[0...5] function returning pointer to int

EQTO *x : array[0...5] function returning pointer to int

EQTO x : pointer to array[0...5] function returning pointer
to int



ex:2 char(*(*y())[])();

(*(*y())[])() : char

EQTO (*(*y())[]) : function returning char

EQTO *(*y())[] : function returning char

EQTO (*y())[] : pointer to function returning char

EQTO (*y()) : array of pointer to function returning char

EQTO *y() : array of pointer to function returning char

EQTO y() : pointer to array of pointer to function returning
char

EQTO y : function returning pointer to array of pointer to
function returning char


1) now my question is how good is this method especially when type
qualifiers come into play??
2) Is it better than right to left rule or using a series of
typedef's
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top