Re: why use -> (not .) with pointers?





Walter Roberson wrote:
>
> If there is no operator for int + float then the programmer would
> have to put in explicit type casts as necessary, thus forcing the
> programmer to pay attention at each substep to the types.

FORTRAN II was like this: An expression had to be
entirely integer or entirely floating-point. Assignment
(which FORTRAN didn't think of as an "operator") could
convert types: INT = REAL or REAL = INT were valid, but
INT + REAL was not.

When FORTRAN IV came along and allowed mixed expressions
my initial reaction was "Why? We've been getting along
fine without them." It didn't take me long to change my
mind, though, and I would not want to return to the old days.

> Such a scheme might do interesting things to expressions such as
> toupper(HexChar) - 'A' + 10
> due to the signed-ness ambiguity of char...

The signedness of `char' does not affect this expression
because the three operands are all of type `int'. The type
of `HexChar' is not shown, but if its value is in fact one of
the letters 'a' through 'f' or 'A' through 'F' then that value
is positive even if `char' is signed.

(Note that the expression is not a bulletproof way to
derive a hex digit's value from a letter, even if the letter
is known to be valid. The codes for these letters need not
be ascending, nor even adjacent. I know of no encoding where
they aren't -- but at least one encoding where 'A' + 25 != 'Z'
exists and is in current use, so there's at least a potential
for unpleasant surprises.)

--
Eric.Sosman@xxxxxxx

.



Relevant Pages

  • Re: Integer types in embedded systems
    ... First, omitting the "int", even if legal, is sloppy and would not ... I compiler doesn't have to do ... You seem to be a beginning embedded programmer, ... Firstly, yes I'm new to embedded systems, but I consider myself to be ...
    (comp.lang.c)
  • Re: Tk in comparison to other portable toolkits
    ... I'm not saying I'm a better programmer, ... Visual * v, Colormap cm, int depth, ... char antialias, char hiq, char blend, char dither_mask, ... Data structures, not algorithms, are central to ...
    (comp.lang.tcl)
  • Re: Integer types in embedded systems
    ... Oh, my, I had no idea that you were the ultimate programmer, better ... regardless of options used when invoking the compiler. ... So what size should int be? ... of int instead of char. ...
    (comp.lang.c)
  • Re: strange compiler message
    ... >> an int but an object of class Foo. ... > Because the user/programmer does not see the functions signature at ... > the programmer is just sloppy. ... the programmer would still know that " blah blah " would not get modified. ...
    (comp.lang.cpp)
  • Re: Sweeney presentation "The Next Mainstream Language"
    ... There is no common supertype for int and real that's also numeric. ... So we're stuck with approximations of reals. ... possibly helped by programmer annotations or checks. ...
    (comp.lang.functional)