Re: mixed mode allowed for comparison macros?



Howard Hinnant wrote:
> In article <1138046748.075526.25410@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
> "Robert Gamble" <rgamble99@xxxxxxxxx> wrote:
>
> > Howard Hinnant wrote:
> > > Is this legal C99?
> > >
> > > #include <math.h>
> > >
> > > int main()
> > > {
> > > float x = 1;
> > > double y = 2;
> > > int b = isgreater(x, y);
> > > }
> >
> > I don't see any reason it wouldn't be, why do you think it might not
> > be?
>
> The standard says:
>
> int isgreater(real-floating x,real-floating y);
>
> To me it is not clear if the two real-floating parameters can have
> different types or not.
>
> Furthermore I have empirical evidence that prominent C committee members
> *might* believe the two parameters should be constrained to the same
> type. From the language in the standard I'm unable to form a firm
> argument for either position.
>
> Why do you think it might be allowed?

I haven't seen this evidence you speak of but from your description it
doesn't sound very persuasive. There are two reasons that I think
mixed types are allowed. First, it would be quite an oversight to
forget to mention that "oh, by the way, this is only defined if x and y
are of the same type" especially when the wording is so otherwise
thorough in that section. The term "real floating-point" is used
several times to describe the type of arguments the macros operate on,
I think that if there were further restrictions it would be easy enough
to say so.

Second, the whole point of the macros is to be able to perform
non-exceptional comparision on real floating-point types. The scope of
the macros would be quite limited is the restriction you suggest were
intended.

kuyper also makes a good case in his response.

Robert Gamble

.



Relevant Pages

  • Re: Python syntax in Lisp and Scheme
    ... If I call a method and pass it a function object, ... > (three functions, or macros, that start, run, and stop the reactor), ... > reason about, compared to something that has the potential to dissect ... Given that I've seen nobody say, for days!, ...
    (comp.lang.python)
  • Re: Why not FILE instead of FILE*?
    ... >>Not bad for a simple minded optimizer. ... There is a reason C is ... What is potentially dangerous in macros like getc and putc? ... Dan Pop ...
    (comp.lang.c)
  • Re: Macros and Excel 2002
    ... The macros are used for a reason - I'm converting a 5,000+ line exported ... HTML file into a particular Excel format and I don't want to do it line by ...
    (microsoft.public.security)
  • Re: Why use assembly?
    ... there is no reason for not doing this in Assembly. ... Example, Assembly HLL-Constructs macros, Assembly Compatible ... the language into something they were familiar with, ... It strikes me as a bad habit and is the reason why I avoid ...
    (alt.lang.asm)
  • Re: Problem for physicalist evolutionists
    ... Sorry but you can't "reason" something into existence. ... the reasoning is based on the empirical evidence. ... You are right that you can't change the nature of reality through ...
    (talk.origins)