Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!inuxc!iuvax!pur-ee!j.cc.purdue.edu!k.cc.purdue.edu!l.cc.purdue.edu!cik From: cik@l.cc.purdue.edu.UUCP Newsgroups: comp.lang.c Subject: Re: Types Message-ID: <541@l.cc.purdue.edu> Date: Wed, 10-Jun-87 14:24:40 EDT Article-I.D.: l.541 Posted: Wed Jun 10 14:24:40 1987 Date-Received: Sat, 13-Jun-87 05:40:04 EDT References: <7264@brl-adm.ARPA> <734@sdchema.sdchem.UUCP>, <293@osupyr.UUCP> <1173@ius2.cs.cmu.edu> Organization: Purdue University Statistics Department Lines: 106 Summary: Clarification of the problems # In article <533@l.cc.purdue.edu>, cik@l.cc.purdue.edu (Herman Rubin) writes: # > In article <8024@utzoo.UUCP>, henry@utzoo.UUCP (Henry Spencer) writes: # > > But this sure doesn't sound like C, and C is what X3J11 is standardizing. # > # > Okay, let me stick to nasty problems with C. # > # > 1. Have the compiler substitute locations in -asm- statements. # > Other than editing the assembler output, I do not believe there # > is any way to insert asm statements which can be expected to # > survive a change from one compiler to another. # # I have no idea what you are talking about. The asm statement # allows you to insert assemble code into your C program, what # is the problem you are having with this? For example, suppose that the variable j has just been computed, and I want to transfer on overflow to loc. On the VAX, in C this is asm(" jov xxx,LLL"); wher xxx is the location of j that the compiler has assigned and LLL is the compiler's symbol for loc. Sometimes, but not always, I can figure out where the compiler has put j, but definitely not loc. The only way I have been able to do this is to put in something for xxx and LLL, get the assembler listing, and then edit it. # > 2. Require that the compiler honor, whenever possible, assignments # > to registers. ^^^^^^^^ # # Is this really a problem? Maybe I've been luckly, but when I ask # for a register I get it provided I haven't used them all yet. On the VAX, the compiler only lets me use half of the registers, and in cases in which I wish to specify that a variable be in a specific register, it refuses completely. It refuses to put floating and double variables in registers. Also, using C compilers for both the VAX and the PYRAMID, I have been unable to get the compiler to put a one-word union in a register. # > # > 3. Allow the programmer to force non-promotion of floating to double, # > whenever the programmer feels there is a good reason to do this. # > I know when there is no point in using double; the compiler cannot. # > Also, on some machines, one cannot print out a floating number in hex. # > (Okay, I can finagle it. But I had an occasion where this would have # > been a problem. I edited the assembler code, as the easiest option.) # # But heres the problem - floatfunc(3.0), should 3.0 be pass as # a float or a double? To complicate matters, say floatfunc is # external. Function prototypes may take care of this though. # # How about this to solve your problem. # # typedef union # { # float fnum; # int inum; # } floatint; # I agree that your solution would work, and I would have used this method if I had foreseen the problem. However, if a variable is typed float, it should be possible to pass it unpromoted in C without having to work. # > 4. Allow floating point numbers to be given in hex. Try putting in # > 2^-32 as a floating point or double constant. Why should one have to # > risk computer roundoff when it is totally unnecessary? # # Some people have noted that this might be a niece feature, I forget # what if any problems there are with this. # There are no problems with this, but I do not know of any notation that has been suggested to do this. # > # > 5. Require that the compiler honor parentheses. When I want a # > subroutine to return (x - y - k*c) + f(y), I most emphatically do # > not want the compiler to do the "obvious" rearrangement to combine # > the two terms with y; this can be a major loss of accuracy. To set # > a variable equal to the parenthetical expression is a significant # > loss of time. # # What two terms with y? I hope my C compiler doesn't think y can # be factor out of that expression to form (f-1)(y) :-). The two terms are -y and f(y). # To address your real complaint, the ANSI standard plans on supporting # parenthesis honoring through the use of the unary +. +(x - y) + y # will be evaluated as it appears. # I have no objection to the unary +, but many of the commentators in this news group seem to. # Please lets not get into a long philosophic debate over this # we have seen it all before. If you don't like it, use another # language. If there were another appropriate language, I would. None of the other languages I know (except PL/1, which is unnecessarily clumsy) do any better. # Eddie Wyatt # # e-mail: edw@ius2.cs.cmu.edu -- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907 Phone: (317)494-6054 hrubin@l.cc.purdue.edu or pur-ee!stat-l!cik or hrubin@purccvm.bitnet