Uses of "short" ?
preece at ccvaxa.UUCP
preece at ccvaxa.UUCP
Wed Sep 11 01:48:00 AEST 1985
> There is an unfortunate tendency for C programmers to think in terms of
> a concrete machine that they're programming for, rather than an
> abstract machine - or, even better, an abstract model of the particular
> computation they're performing. Thinking of data objects not as lumps
> of machine words but as abstractions will, I suspect, improve the
> quality of your code in general, and specifically its portability. /*
> Written 12:58 am Sep 6, 1985 by guy at sun.uucp in ccvaxa:net.lang.c */
----------
But 'int' is a perfectly good abstraction; more abstract that 'short'
or 'long.' The restriction of certain values to certain ranges CAN
be part of an abstraction, but it can also be an incidental factor
that is only useful because some machines make a distinction that
makes it useful. That says to me that use of 'short' or 'long'
instead of 'int' shows more attention to machine specificity.
It may be the case that in a certain piece of code it is possible
to prove that a variable's value must lie in a particular range.
If the programmer specifies that range somehow, compilers for
languages that support that distinction can produce code taking
advantage of it. From the programmer's point of view, however,
that provable range is probably not significant to her view of
the process. Often it doesn't matter to the programmer whether the
variable is real or integer, either, but that abstraction is more
deeply ingrained.
--
scott preece
gould/csd - urbana
ihnp4!uiucdcs!ccvaxa!preece
More information about the Comp.lang.c
mailing list