Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!ames!uhccux!munnari.oz.au!cs.mu.oz.au!ok From: ok@cs.mu.oz.au (Richard O'Keefe) Newsgroups: comp.lang.c Subject: Re: Type punning in C Keywords: I AGREE! Message-ID: <2411@munnari.oz.au> Date: 13 Oct 89 06:01:22 GMT References: <475@idacrd.UUCP> <1989Oct10.185851.6490@agate.berkeley.edu> <4055@deimos.cis.ksu.edu> Sender: news@cs.mu.oz.au Lines: 32 In article <4055@deimos.cis.ksu.edu>, mac@harris.cis.ksu.edu (Myron A. Calhoun) writes: : In article <1654@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: : >This is another example of those "gurus" who can not envision an intelligent : >user using the machine in an intelligent manner, and prevent that use. I : >have deliberately used "type punning" on various machines, and I consider it : >an extremely useful tool..... : I agree wholeheartedly. FORTRAN doesn't have PL/1's UNSPEC verb, yet : I have had occasion to want it. And EQUIVALENCE provided it. : Calling a subroutine with "wrong" type parameters can also work: : CALL NEWTYP (INTEGER,...) : ::::: : SUBROUTINE NEWTYP (REAL,...) I shall try to tell you what the point is in words that have but one sound in them. Those who write books that say what a tool like C means want to help you make tools that can be used on more than one box. I shall say it one more time: "that can be used on more than one box". A type pun is all but sure to work on at most one box. This means that those who write books that say what a tool like C means MUST tell you not to trust type puns. This does not mean that type puns will not work on your box. It just means that those who write books that say what a tool like C means had to tell you that it might not work. They could not rule that the same pun must work on each box, since they do not tell those who make each box what to do. Nor do they tell YOU what to do, just what you can TRUST. If a type pun works on your box, use it, but keep in mind that it may not work on aught else. [PS: UNSPEC is not a "verb" in PL/I, it is a "pseudo-function", and it is very far from being portable. It's a _major_ pain when trying to port PL/I programs. ]