Re: why use -> (not .) with pointers?
- From: Eric Sosman <eric.sosman@xxxxxxx>
- Date: Thu, 30 Jun 2005 14:27:09 -0400
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
.
- References:
- why use -> (not .) with pointers?
- From: Felix Kater
- Re: why use -> (not .) with pointers?
- From: Guillaume
- Re: why use -> (not .) with pointers?
- From: Richard Tobin
- Re: why use -> (not .) with pointers?
- From: Guillaume
- Re: why use -> (not .) with pointers?
- From: Walter Roberson
- why use -> (not .) with pointers?
- Prev by Date: Re: How to make binary data portable?
- Next by Date: Re: how to let gcc warn me when I use = in conditions
- Previous by thread: Re: why use -> (not .) with pointers?
- Next by thread: Re: why use -> (not .) with pointers?
- Index(es):
Relevant Pages
|