Typeof operator in C (Re: An Interesting View of "Strong" Vs. "Weak" Typing)

Bruce Becker bdb at becker.UUCP
Sun Jan 14 07:32:03 AEST 1990


In article <-K016ODxds13 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
|> This last sentence bothers me.  It would be quite simple to implement
|> a C operator such as "(typeof) x" that returns some representation of
|> the type of the variable x.
|
|I think this would be a worthwhile innovation, and one that's as easy
|to implement as sizeof. It wouldn't return a value, but would be used
|anywhere a type could be used.
|[...]
|But a typeof operator... wouldn't that be something...
|
|#define SWAP(a,b) {typeof a tmp; tmp=a; a=b; b=tmp}

	I believe that much of what you speak of
	is contained in the PL/1 operator "LIKE",
	although I'm not sure if it applies to
	anything else but structures in that language.

	This example can be implemented in a similar
	fashion in PL/1 to the above...

-- 
  ,,,,	 Bruce Becker	Toronto, Ont.
w \$$/	 Internet: bdb at becker.UUCP, bruce at gpu.utcs.toronto.edu
 `/c/-e	 BitNet:   BECKER at HUMBER.BITNET
_/  >_	 "Money is the root of all money" - Adam



More information about the Comp.lang.c mailing list