comp.lang.ada
 help / color / mirror / Atom feed
* Re: Problems in C and Ada
@ 1982-11-01  2:11 duke!bcw
  1982-11-01  2:32 ` Rounding of Fixed Point in Ada eagle!cw
  0 siblings, 1 reply; 2+ messages in thread
From: duke!bcw @ 1982-11-01  2:11 UTC (permalink / raw)


From:	Bruce C. Wrigt @ Duke University
Re:	Problems in C and Ada

The overloading capabilities of Ada are definitely not the *worst* feature
of the language;  in fact there are very few languages which do *not* have
some amount of overloading (usually small).  Forth, Bliss, and BCPL are the
only languages which come to my mind immediately which have *no* overloading -
most languages implicitly overload operators like + so that they work with
both integer and floating point arithmetic.  Ada and a couple of other
languages allow the user to define additional overloaded operations.  I
don't agree with the way it's done (I don't think it should be legal for
the programmer to hide the system-defined instance of the "+" operator for
integers, for example;  probably at least the operators should be defined
in some kind of encapsulation where the data type itself is defined and
modification of the operators outside of the encapsulation should probably
be illegal), but it does not strike me as an unreasonable idea.

A much worse problem with Ada (unless the revised report has fixed the
problem) is with the definition of fixed-point data.  This is an attempt
to allow a "poor man's floating point" by defining a number with a radix
point (similar to PL/I's fixed point data).  The problem is that the old
version of the language did not define the radix in which the fixed-point
data was to be stored;  it just allowed the programmer to specify a delta
value which is guaranteed to be greater than or equal to the smallest possible
difference between two numbers.  For example, if you specify a delta value
of 0.1, the compiler could comply both if it compiled your data type as a
fixed decimal number with one digit to the right of the decimal point, or
a fixed binary number with four bits to the right of the decimal point
(hence the "actual" delta would be 0.0625).  This will cause obscure problems
with portability and verification of code which uses the feature, since
there will be unpredictable rounding effects depending on the implementation.

There were several other problems with the initial report, which I think
have been fixed in the final report, so this may have been fixed as well;
there are several other things which they did which look much more
questionable than overloading.

			Bruce C. Wright @ Duke University

PS -- I have noted that many people on the net misspell the name of the
      PL/I language.  The name is not PL/1, PL-1 or whatever;  the ANSI
      committee specifically states that the correct spelling is PL/I.

				-- BCW



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Rounding of Fixed Point in Ada
  1982-11-01  2:11 Problems in C and Ada duke!bcw
@ 1982-11-01  2:32 ` eagle!cw
  0 siblings, 0 replies; 2+ messages in thread
From: eagle!cw @ 1982-11-01  2:32 UTC (permalink / raw)



A recent article refers to Ada fixed point as a kind of
"poor man's floating point."  It is not that at all.
First, it is in the language not because the designers necessarily
wanted it there, but because the language specifications demanded it.
Second, it attempts to provide the facility to manipulate data with a
truly fixed radix point.  The most common instance of this kind
of data is money (with exactly two decimal places in the US), but much 
sensor data also has this property.  Remember that Ada is a
language for programs that handle real world external data.

Third, the radix for fixed point numbers is (implicitly) binary,
albeit the delta can be expressed in decimal.  Finally, although
the rounding rules are not easy to explain for Ada numbers
(either fixed point or floating point), they are considerably
more precise than are the rules in most languages.  Should
a program be one where detailed rounding control is necessary,
Ada is more likely to provide that control than other languages.

If there is to be more Ada discussion, should it be moved to
net.lang.ada?

Charles



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1982-11-01  2:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1982-11-01  2:11 Problems in C and Ada duke!bcw
1982-11-01  2:32 ` Rounding of Fixed Point in Ada eagle!cw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox