Re: Surprise in array concatenation



On Tue, 06 Sep 2005 17:51:11 +0200, Georg Bauhaus wrote:

> Dmitry A. Kazakov wrote:
>> On Tue, 06 Sep 2005 13:52:53 +0200, Georg Bauhaus wrote:
>>
>> The violation is in inability to construct empty arrays and ranges for some
>> types.
>
> Many kinds of structured data cannot be constructed
> from Ada's types because of Ada's rules. How does this violate Ada's
> contracts?

If those aren't abstract types, it does.

> A contract is not necessarily simple, nor without deliberately
> chosen limitations.

Arbitrary limitations you mean. If an unbounded array type is not allowed
to have empty instances, then I expect to see that explicitly specified in
the contract. Soon Ada will have never-null access types. It also could
have never-empty arrays, but only this way.

>> That becomes funny. What is a "finite" value? Is 1/3 finite? What about
>> 0.1? (:-))
>
> Earlier I said, forget about real numbers (from mathematics) in real
> computers. 1/3 is indeed an example in binary computers: An interval
> representing two real numbers close to 1/3 is not 1/3, and you cannot
> hope to be computing using real numbers using the facilities of a
> real computing machine. That is because almost all reals cannot be
> represented in a finite computer.

Nope. You confuse sets and elements. Any infinite subset of R (and R
itself) cannot be represented by *specifying its members*, because they
aren't countable. But any real and any finite real subset can. Further any
set can be represented by other means.

The domain set of a type need not to be countable. Neither you need to
count all values of a type in a given program. Did you ever use all
possible values of Integer? Nevertheless, you can do all sorts of quite
useful things without that. Now imagine that there are more integers than
that. Would it change anything for you? Not in a well designed program!

Note an important point of Ada design, as opposed to may other languages.
In Ada you specify what kind of values you are going to use. You say:

My_Integer is range 0..100;
-- I don't care about other integers
My_Float is digits 8 range 0.0..100.0;
-- I don't care about reals outside and in between

This is the right way to handle uncountable things without inventing any
new "computer" mathematics, where an element is not element and greater is
less.

>> LOL! Any program represents anything symbolically.
>
> No, an executing program has an interpretation.
> This makes "representing" have a meaning.

And meaning is represented by what? (:-))

>> Do you really believe
>> that 1 is *the* 1? Did you see a label "made in Heaven" on it? (:-))
>
> Type Positive starts at 1 and ends with Positive'Last.

.... and it does this not symbolically, but physically by attaching a tiny
rubber thread to the Platonic number 1. Right? (:-))

> The fact that A'First doesn't always refer
> to an element is not different from the fact that A'Length / 2
> doesn't always refer to an element, even when the array isn't empty.
> Of what use is the test A'Length = 0 in this case?

A'Length and A'First have different types. Ada is a typed language!

You are trying to formulate some generic algorithm which does not work for
all index types. This is why it is so important to have a consistent model
of indexing and arrays. For an unordered [index] type X it is wrong to
assume that:

1. If L in X and U in X then there is always M in X between L and U
2. That M can be computed as (L+U)/2

Examples: hash map, variable length string map etc.

The contracts like 1&2 have be stated, not implied ones, if the application
have to rely on them.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages

  • Re: % question
    ... All integers are reals, all reals are complex, and all ... Lancelot Hogben, "Mathematics for the Million". ... they need to use and even program computers ... One model of education is that they must learn one thing at a time as ...
    (comp.lang.c)
  • Re: Ada.Strings.Bounded
    ... In any language describing these machines, ... you can do with computers, ... there's no total ordering on such intervals, ...
    (comp.lang.ada)
  • Re: printf("%p ", (void *)0);
    ... > Antoine Leca wrote: ... >> I really read that a complex has the same alignment contraint as ... >> an array of two corresponding reals, as opposed for example to a ... post re Dan about an inference of him jumping from arrays to the element ...
    (comp.lang.c)
  • Re: Computable functions/reals.
    ... Computers don't do calculations with real numbers. ... - Reals numbers aren't really ... "Understanding Godel isn't about following his formal proof. ...
    (sci.logic)
  • Re: Computable functions/reals.
    ... Computers don't do calculations with real numbers. ... Any machine that writes one character at ... Reals numbers aren't really ...
    (sci.logic)