Path: utzoo!attcan!ncrcan!becker!bdb From: bdb@becker.UUCP (Bruce Becker) Newsgroups: comp.lang.c Subject: Re: Typeof operator in C (Re: An Interesting View of "Strong" Vs. "Weak" Typing) Message-ID: <2165@becker.UUCP> Date: 13 Jan 90 20:32:03 GMT References: <16678@megaron.cs.arizona.edu> <7106@tank.uchicago.edu> <-K016ODxds13@ficc.uu.net> Reply-To: bdb@becker.UUCP (Bruce Becker) Organization: G. T. S., Toronto, Ontario Lines: 26 In article <-K016ODxds13@ficc.uu.net> peter@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@becker.UUCP, bruce@gpu.utcs.toronto.edu `/c/-e BitNet: BECKER@HUMBER.BITNET _/ >_ "Money is the root of all money" - Adam