From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Ada.Strings.Bounded
Date: Mon, 21 Apr 2008 14:04:56 -0400
Date: 2008-04-21T14:04:56-04:00 [thread overview]
Message-ID: <wcck5ir84on.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 15514187-d7d0-4650-a058-13ec5684be2c@w5g2000prd.googlegroups.com
Eric Hughes <eric.eh9@gmail.com> writes:
> On Apr 21, 8:08 am, Robert A Duff <bobd...@shell01.TheWorld.com>
> wrote:
>> Anyway, it might make your point clearer if you explain it again,
>> but using proper Ada terminology this time.
>
> I will endeavor to use Ada terminology when I can, but there is not
> Ada terminology for some of the things I'm talking about. I'll start
> back at the beginning of the argument I made just previously. I'm
> stripping this argument down to its basics. I've removed any piece of
> the argument that includes anything that might be mistaken for an Ada
> arithmetic operation.
OK, thanks. I think I get it now.
> Eric Hughes <eric....@gmail.com> writes:
>> Every universal_integer has a literal expression 'm'.
>
> Let N0 be the value in {\bb N} for this universal integer. This N0 is
> not an Ada natural, it's a mathematical one. I will presume that
> there is an injective map from universal_integer into {\bb Z} that
> preserves value. I would find it absurd to disagree with this
> premise, but I'd rather make it explicit than not.
>
> What I mean by what I said is that there a sequence of characters 'm'
> that, when used as a static_expression in a number_declaration
> (3.3.2/2), creates an Ada constant whose value is equal to N0. 'm' is
> not an Ada construct, it's a sequence of characters valid for
> substitution into an Ada program. Furthermore, we can find such an
> 'm' that is valid as a 'numeral' (2.4.1/3), consisting only of
> digits. Since I was only discussing positive upper bounds and
> 'numeral' has no minus sign in its syntax, this sequence of characters
> is unique and always exists.
>
> Eric Hughes <eric....@gmail.com> writes:
>> The expression 'm+1' is also a literal.
>
> Let N1 = N0 + 1. N1 is also in {\bb N}. There's another sequence of
> characters, which I called 'm+1', again also valid as an Ada
> 'numeral', that has the value N1. We compute this using outside-of-
> Ada ordinary mathematical operations. ARM 2.4.1 "Decimal Literals"
> has no length limitation on 'numeral'.
OK, so m is some sequence of characters -- an integer literal.
That's what I was confused about before.
(Nit: an implementation is allowed to restrict integer literals
to 200 characters. See RM-2.2(14). It is not required to do
so, and anyway, it doesn't change the fact that there are an
infinite number of integers.)
> Eric Hughes <eric....@gmail.com> writes:
>> All literals have type universal_integer (see 2.4/3).
>> Therefore 'm+1' is also a universal_integer.
>
> Admittedly I was only talking about integer literals; other literals
> have different types. The term "integer literal" is defined in ARM
> 2.4/1:
>> an integer literal is a numeric_literal without a point
> Both sequences of characters 'm' and 'm+1' consist only of digits, so
> each is also valid as an "integer literal".
>
> So far I've only dealt with syntactic issues. I need to now make an
> assertion about type. From ARM 2.4/3:
>> The type of an integer literal is universal_integer.
>
> I see two arguably-correct ways of interpreting this statement, one
> absolute and one contingent:
> -- Every integer literal has a type and that type is
> universal_integer.
> -- If an integer literal has a type, that type is universal_integer.
> I believe the contingent version is not the meaning.
Yes. Every integer literal has type univ_int.
>...The ARM
> statement is written in unconditional language. "The type of an
> integer literal" identifies the unique type associated with that
> integer literal and implies that there is always such a type. The
> contingent version of this sentence would be "The type of an integer
> literal, if any, is universal_integer." But that's not what it says.
>
> Hence both 'm' and 'm+1' have a type, and that that type is
> universal_integer. By induction, universal_integer has no upper
> bound.
Sure. But I don't see the need for all this song and dance,
since AARM-3.5.4 says:
8 The set of values for a signed integer type is the (infinite) set of
mathematical integers[, though only values of the base range of the type are
fully supported for run-time operations]. The set of values for a modular
integer type are the values from 0 to one less than the modulus, inclusive.
We all know there are an infinite number of integers, so why did
you want to prove it? Universal_integer is not special in this
regard. And for compile time (static) calculations, Ada places
no limit on the size of integers.
> On Apr 21, 8:08 am, Robert A Duff <bobd...@shell01.TheWorld.com>
> wrote:
>> The expression 'm+1' is certainly NOT a literal -- it's a function
>> call, passing an identifier and a literal as the actual parameters.
>
> I redid the argument to get rid of this ambiguity. Admittedly I had
> not distinguished addition on {\bb N} and addition on Ada types. My
> argument doesn't rely upon addition on any Ada type.
OK, I see.
But you could rely on integer addition (for static values of type
root_integer, for example).
>> Universal_integers can be
>> implicitly converted to various integer types.
>
> This was the whole point of the discussion--why such implicit
> conversions do not break the type system. It's not like integers are
> a tagged type.
>
>> type My_Int is range 1..100;
>> Y : constant My_Int := 1 + 1; -- The "+" of My_Int is called.
>> -- Y is of type My_Int.
>
> Are there other places in Ada when the context of an operation
> determines the type of the operands of the function and thus also the
> function signature?
Overload resolution always takes the context into account,
for function calls. Nothing special about "+" in that regard.
If you say:
P(Param => F(X));
Then the type of Param helps determine which F is called (if there are
many functions called F that are directly visible). The type of X also
helps determine which F is called -- and there might be several
overloaded X's. There might also be several P's, some of which have
a Param.
> Context-dependent function selection need not break correctness of a
> program, even when there's ambiguity in what function might be
> selected (non-deterministic execution). The conditions for this to
> work are implicitly present with integer types.
Seems like "need not break" isn't good enough -- I want to prove that it
"does not break". There could be a user-defined "+".
>...I believe it's
> possible to make them explicit for arbitrary types.
Hmm. I guess I need an example to see what you're getting at.
Choosing which function to call nondeterministically seems
like an Obviously Bad Idea, to me, so perhaps I don't understand
what you mean.
- Bob
next prev parent reply other threads:[~2008-04-21 18:04 UTC|newest]
Thread overview: 108+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-31 22:44 Untyped Ada? Phaedrus
2008-04-01 0:16 ` Randy Brukardt
2008-04-01 7:19 ` tmoran
2008-04-01 7:44 ` Dmitry A. Kazakov
2008-04-01 8:28 ` Jean-Pierre Rosen
2008-04-01 21:44 ` Phaedrus
2008-04-01 21:51 ` Ludovic Brenta
2008-04-01 17:09 ` Pascal Obry
2008-04-01 22:00 ` Phaedrus
2008-04-02 7:31 ` Dmitry A. Kazakov
2008-04-04 15:16 ` Graham
2008-04-04 16:10 ` Pascal Obry
2008-04-04 21:09 ` Ada.Bounded_Strings Adam Beneschan
2008-04-04 21:15 ` Ada.Strings.Bounded Adam Beneschan
2008-04-05 4:39 ` Ada.Strings.Bounded Gautier
2008-04-05 9:43 ` Ada.Strings.Bounded Pascal Obry
2008-04-05 10:10 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-05 11:36 ` Ada.Strings.Bounded Gautier
2008-04-05 12:14 ` Ada.Strings.Bounded Pascal Obry
2008-04-06 0:31 ` Ada.Strings.Bounded Randy Brukardt
2008-04-07 14:57 ` Ada.Strings.Bounded Adam Beneschan
2008-04-07 15:23 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-07 16:34 ` Ada.Strings.Bounded stefan-lucks
2008-04-07 17:34 ` Ada.Strings.Bounded (see below)
2008-04-12 18:50 ` Ada.Strings.Bounded Eric Hughes
2008-04-12 19:46 ` Ada.Strings.Bounded Georg Bauhaus
2008-04-13 16:53 ` Ada.Strings.Bounded Eric Hughes
2008-04-13 20:10 ` Ada.Strings.Bounded Robert A Duff
2008-04-13 23:52 ` Ada.Strings.Bounded Eric Hughes
2008-04-14 8:00 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-14 15:25 ` Ada.Strings.Bounded Eric Hughes
2008-04-14 18:36 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-15 1:39 ` Ada.Strings.Bounded Eric Hughes
2008-04-12 21:09 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-13 16:31 ` Ada.Strings.Bounded Eric Hughes
2008-04-13 20:02 ` Ada.Strings.Bounded Robert A Duff
2008-04-13 23:20 ` Ada.Strings.Bounded Eric Hughes
2008-04-14 9:07 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-14 15:50 ` Ada.Strings.Bounded Eric Hughes
2008-04-14 18:52 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-15 2:07 ` Ada.Strings.Bounded Eric Hughes
2008-04-15 8:02 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-15 14:20 ` Ada.Strings.Bounded Eric Hughes
2008-04-15 15:23 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-16 2:51 ` Ada.Strings.Bounded Eric Hughes
2008-04-16 8:00 ` Ada.Strings.Bounded Dmitry A. Kazakov
[not found] ` <bc3a8b4e-63fe-47a6-b10b-7056f6d7d586@w5g2000prd.googlegroups.com>
2008-04-15 14:58 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-16 2:46 ` Ada.Strings.Bounded Eric Hughes
2008-04-16 8:16 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-16 14:40 ` Ada.Strings.Bounded Eric Hughes
2008-04-16 18:28 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-21 0:44 ` Ada.Strings.Bounded Eric Hughes
2008-04-21 14:08 ` Ada.Strings.Bounded Robert A Duff
2008-04-21 16:35 ` Ada.Strings.Bounded Eric Hughes
2008-04-21 18:04 ` Robert A Duff [this message]
2008-04-22 0:19 ` Ada.Strings.Bounded Eric Hughes
2008-04-22 0:49 ` Ada.Strings.Bounded Adam Beneschan
2008-04-22 1:02 ` Ada.Strings.Bounded Adam Beneschan
2008-04-22 15:30 ` Ada.Strings.Bounded Eric Hughes
2008-04-22 16:08 ` Ada.Strings.Bounded Robert A Duff
2008-04-22 15:25 ` Ada.Strings.Bounded Eric Hughes
2008-04-22 15:54 ` Ada.Strings.Bounded Robert A Duff
2008-04-22 15:41 ` Ada.Strings.Bounded Robert A Duff
2008-04-22 17:49 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-22 18:26 ` Ada.Strings.Bounded Samuel Tardieu
2008-04-22 18:59 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-22 18:47 ` Ada.Strings.Bounded Eric Hughes
2008-04-22 19:19 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-22 19:41 ` Ada.Strings.Bounded Robert A Duff
2008-04-22 22:55 ` Ada.Strings.Bounded Eric Hughes
2008-04-23 6:40 ` Ada.Strings.Bounded christoph.grein
2008-04-23 6:54 ` Ada.Strings.Bounded christoph.grein
2008-04-23 10:42 ` Ada.Strings.Bounded Georg Bauhaus
2008-04-23 12:32 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-23 12:52 ` Ada.Strings.Bounded christoph.grein
2008-04-23 13:34 ` Ada.Strings.Bounded Georg Bauhaus
2008-04-23 15:12 ` Ada.Strings.Bounded Adam Beneschan
2008-04-23 15:36 ` Ada.Strings.Bounded (see below)
2008-04-23 17:09 ` Ada.Strings.Bounded Ray Blaak
2008-04-24 0:29 ` Ada.Strings.Bounded Randy Brukardt
2008-04-22 20:15 ` Ada.Strings.Bounded Adam Beneschan
2008-04-23 13:14 ` Ada.Strings.Bounded Peter Hermann
2008-04-23 14:40 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-23 15:03 ` Ada.Strings.Bounded Adam Beneschan
2008-04-22 19:56 ` Ada.Strings.Bounded Adam Beneschan
2008-04-21 18:50 ` Ada.Strings.Bounded Dmitry A. Kazakov
2008-04-22 0:31 ` Ada.Strings.Bounded Eric Hughes
2008-04-14 15:11 ` Ada.Strings.Bounded Adam Beneschan
2008-04-14 16:09 ` Ada.Strings.Bounded Eric Hughes
2008-04-14 18:13 ` Ada.Strings.Bounded Georg Bauhaus
2008-04-15 1:35 ` Ada.Strings.Bounded Eric Hughes
2008-04-15 20:33 ` Ada.Strings.Bounded Georg Bauhaus
2008-04-16 3:11 ` Ada.Strings.Bounded Eric Hughes
2008-04-04 23:35 ` Ada.Bounded_Strings Robert A Duff
2008-04-05 1:46 ` Ada.Bounded_Strings Adam Beneschan
2008-04-05 4:55 ` Ada.Bounded_Strings Randy Brukardt
2008-04-05 7:30 ` Ada.Bounded_Strings Dmitry A. Kazakov
2008-04-06 0:44 ` Ada.Bounded_Strings Randy Brukardt
2008-04-04 16:18 ` Untyped Ada? Adam Beneschan
2008-04-04 16:32 ` DScott
2008-04-04 17:38 ` Dmitry A. Kazakov
2008-04-04 18:52 ` Georg Bauhaus
2008-04-05 8:07 ` Dmitry A. Kazakov
2008-04-04 19:14 ` Graham
2008-04-04 21:06 ` tmoran
2008-04-05 8:44 ` Dmitry A. Kazakov
2008-04-12 16:50 ` Eric Hughes
2008-04-04 18:02 ` adaworks
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox