[net.lang.c] adjectives for typedef'd names

gam@proper.UUCP (05/09/84)

Are type adjectives (unsigned, etc) allowed as adjectives
to typedef'd identifiers?  e.g. typedef int x; func() {
unsigned x y; }.
Section 18.2, appendix a of THE BOOK appears to allow it
syntactically.   However, since typedef'd names are also
allowed as structure member names and structure tags, the
structure declaration unsigned x; would appear to be 
bM4ambiguous, or at least non-LR(1)..
Section 11.1 of K&R says that typedef'd names can be
identifiers in inner blocks.  If adjectives are allowed
for typedef'd names, the example in 11.1 is more
interesting if "float' is changed to 'int' and 'int'
is changed to 'unsigned'.
I favor not allowing adjectives on typedef'd names.

gam@proper.UUCP (05/09/84)

Are type adjectives (unsigned, etc) allowed as adjectives
to typedef'd identifiers?  e.g.
	typedef int x;

	func() {
		unsigned x y;
	}

Section 18.2, appendix a of THE BOOK appears to allow it
syntactically.   However, since typedef'd names are also
allowed as structure member names and structure tags, the
structure declaration unsigned x; would appear to be 
ambiguous, or at least non-LR(1)

Section 11.1 of K&R says that typedef'd names can be
identifiers in inner blocks.  If adjectives are allowed
for typedef'd names, the example in 11.1 is more
interesting if "float" is changed to 'int' and 'int'
is changed to 'short':

	typedef int distance;
	main () {
		short distance;
	...
	}

Is `short distance' declaration with no declarator list (as
`short int;'), or a declaration of a `short [int]'
called `distance'?

chris@umcp-cs.UUCP (05/12/84)

PCC happens to treat ``typedef''ed names exactly the same as the
thing to which they are typed.  (At least, if you say

	typedef int foo;

	main () {
		register unsigned foo i;
		short foo;
		...
	}

you get one ``register unsigned int'' and no ``short int''s.)  I
prefer this, because this is the way I think of them.  In fact I
used to get the order of ``typedef'' backwards, because I thought
of them as ``glorified #define's''.  (The one advantage they have
over #define's is that they can make things syntactically simpler,
e.g.,

	typedef int (*pfun)();	/* pointer to function returning int */
	pfun table[] = { ... };	/* a table of pointers to functions */

.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland