Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Ada.Strings...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 78 of 109 Topic 5630 of 5827
Post > Topic >>

Re: Ada.Strings.Bounded

by Robert A Duff <bobduff@[EMAIL PROTECTED] > Apr 21, 2008 at 02:04 PM

Eric Hughes <eric.eh9@[EMAIL PROTECTED]
> writes:

> On Apr 21, 8:08 am, Robert A Duff <bobd...@[EMAIL PROTECTED]
>
> 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....@[EMAIL PROTECTED]
> 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....@[EMAIL PROTECTED]
> 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....@[EMAIL PROTECTED]
> 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 sup****ted 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...@[EMAIL PROTECTED]
>
> 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
 




 109 Posts in Topic:
Untyped Ada?
"Phaedrus" <  2008-03-31 14:44:43 
Re: Untyped Ada?
"Randy Brukardt"  2008-03-31 19:16:01 
Re: Untyped Ada?
tmoran@[EMAIL PROTECTED]   2008-04-01 02:19:09 
Re: Untyped Ada?
"Dmitry A. Kazakov&q  2008-04-01 09:44:02 
Re: Untyped Ada?
Jean-Pierre Rosen <ros  2008-04-01 10:28:59 
Re: Untyped Ada?
"Phaedrus" <  2008-04-01 13:44:25 
Re: Untyped Ada?
Pascal Obry <pascal@[E  2008-04-01 19:09:26 
Re: Untyped Ada?
"Phaedrus" <  2008-04-01 14:00:15 
Re: Untyped Ada?
"Dmitry A. Kazakov&q  2008-04-02 09:31:07 
Re: Untyped Ada?
<adaworks@[EMAIL PROTE  2008-04-04 11:02:08 
Re: Untyped Ada?
Ludovic Brenta <ludovi  2008-04-01 23:51:39 
Re: Untyped Ada?
Graham <graham.stark@[  2008-04-04 08:16:04 
Re: Untyped Ada?
Pascal Obry <pascal@[E  2008-04-04 18:10:31 
Re: Untyped Ada?
DScott <Merlin43PhD@[E  2008-04-04 11:32:39 
Re: Untyped Ada?
"Dmitry A. Kazakov&q  2008-04-04 19:38:19 
Re: Untyped Ada?
Adam Beneschan <adam@[  2008-04-04 09:18:42 
Re: Untyped Ada?
Georg Bauhaus <rm.plus  2008-04-04 20:52:38 
Re: Untyped Ada?
"Dmitry A. Kazakov&q  2008-04-05 10:07:42 
Re: Untyped Ada?
Graham <graham.stark@[  2008-04-04 12:14:38 
Re: Untyped Ada?
tmoran@[EMAIL PROTECTED]   2008-04-04 16:06:29 
Re: Untyped Ada?
"Dmitry A. Kazakov&q  2008-04-05 10:44:00 
Re: Ada.Bounded_Strings
Adam Beneschan <adam@[  2008-04-04 14:09:27 
Re: Ada.Bounded_Strings
Robert A Duff <bobduff  2008-04-04 19:35:37 
Re: Ada.Strings.Bounded
Adam Beneschan <adam@[  2008-04-04 14:15:13 
Re: Ada.Strings.Bounded
Gautier <gautier@[EMAI  2008-04-05 06:39:44 
Re: Ada.Strings.Bounded
Pascal Obry <pascal@[E  2008-04-05 11:43:39 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-05 12:10:41 
Re: Ada.Strings.Bounded
Gautier <gautier@[EMAI  2008-04-05 13:36:42 
Re: Ada.Strings.Bounded
Pascal Obry <pascal@[E  2008-04-05 14:14:41 
Re: Ada.Strings.Bounded
"Randy Brukardt"  2008-04-05 19:31:48 
Re: Ada.Bounded_Strings
Adam Beneschan <adam@[  2008-04-04 18:46:52 
Re: Ada.Bounded_Strings
"Randy Brukardt"  2008-04-04 23:55:56 
Re: Ada.Bounded_Strings
"Dmitry A. Kazakov&q  2008-04-05 09:30:30 
Re: Ada.Bounded_Strings
"Randy Brukardt"  2008-04-05 19:44:26 
Re: Ada.Strings.Bounded
Adam Beneschan <adam@[  2008-04-07 07:57:55 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-07 17:23:19 
Re: Ada.Strings.Bounded
stefan-lucks@[EMAIL PROTE  2008-04-07 18:34:54 
Re: Ada.Strings.Bounded
"(see below)" &  2008-04-07 18:34:17 
Re: Untyped Ada?
Eric Hughes <eric.eh9@  2008-04-12 09:50:24 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-12 11:50:56 
Re: Ada.Strings.Bounded
Georg Bauhaus <rm.tsoh  2008-04-12 21:46:45 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-12 23:09:12 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-13 09:31:17 
Re: Ada.Strings.Bounded
Robert A Duff <bobduff  2008-04-13 16:02:49 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-13 09:53:16 
Re: Ada.Strings.Bounded
Robert A Duff <bobduff  2008-04-13 16:10:36 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-13 16:20:24 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-14 11:07:47 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-13 16:52:00 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-14 10:00:04 
Re: Ada.Strings.Bounded
Adam Beneschan <adam@[  2008-04-14 08:11:04 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-14 08:25:41 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-14 20:36:25 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-14 08:50:21 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-14 20:52:16 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-15 10:02:31 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-15 16:58:12 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-16 10:16:44 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-16 20:28:52 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-15 17:23:56 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-16 10:00:23 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-14 09:09:27 
Re: Ada.Strings.Bounded
Georg Bauhaus <rm.tsoh  2008-04-14 20:13:03 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-14 18:35:05 
Re: Ada.Strings.Bounded
Georg Bauhaus <rm.tsoh  2008-04-15 22:33:31 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-14 18:39:46 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-14 19:07:25 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-15 06:56:57 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-15 07:20:15 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-15 19:46:12 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-15 19:51:17 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-15 20:11:04 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-16 07:40:32 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-20 17:44:56 
Re: Ada.Strings.Bounded
Robert A Duff <bobduff  2008-04-21 10:08:16 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-21 20:50:16 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-21 09:35:36 
Re: Ada.Strings.Bounded
Robert A Duff <bobduff  2008-04-21 14:04:56 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-22 19:49:10 
Re: Ada.Strings.Bounded
Samuel Tardieu <sam@[E  2008-04-22 20:26:31 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-21 17:19:52 
Re: Ada.Strings.Bounded
Robert A Duff <bobduff  2008-04-22 11:41:29 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-22 20:59:27 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-21 17:31:37 
Re: Ada.Strings.Bounded
Adam Beneschan <adam@[  2008-04-21 17:49:39 
Re: Ada.Strings.Bounded
Adam Beneschan <adam@[  2008-04-21 18:02:45 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-22 08:25:13 
Re: Ada.Strings.Bounded
Robert A Duff <bobduff  2008-04-22 11:54:34 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-22 08:30:24 
Re: Ada.Strings.Bounded
Robert A Duff <bobduff  2008-04-22 12:08:49 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-22 11:47:05 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-22 21:19:27 
Re: Ada.Strings.Bounded
Robert A Duff <bobduff  2008-04-22 15:41:10 
Re: Ada.Strings.Bounded
Georg Bauhaus <rm.dash  2008-04-23 12:42:32 
Re: Ada.Strings.Bounded
"Randy Brukardt"  2008-04-23 19:29:17 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-23 14:32:16 
Re: Ada.Strings.Bounded
Adam Beneschan <adam@[  2008-04-22 12:56:20 
Re: Ada.Strings.Bounded
Adam Beneschan <adam@[  2008-04-22 13:15:24 
Re: Ada.Strings.Bounded
Peter Hermann <ica2ph@  2008-04-23 13:14:24 
Re: Ada.Strings.Bounded
"Dmitry A. Kazakov&q  2008-04-23 16:40:28 
Re: Ada.Strings.Bounded
Eric Hughes <eric.eh9@  2008-04-22 15:55:09 
Re: Ada.Strings.Bounded
christoph.grein@[EMAIL PR  2008-04-22 23:40:55 
Re: Ada.Strings.Bounded
christoph.grein@[EMAIL PR  2008-04-22 23:54:06 
Re: Ada.Strings.Bounded
christoph.grein@[EMAIL PR  2008-04-23 05:52:24 
Re: Ada.Strings.Bounded
Georg Bauhaus <rm.dash  2008-04-23 15:34:06 
Re: Ada.Strings.Bounded
Adam Beneschan <adam@[  2008-04-23 08:03:42 
Re: Ada.Strings.Bounded
Adam Beneschan <adam@[  2008-04-23 08:12:24 
Re: Ada.Strings.Bounded
"(see below)" &  2008-04-23 16:36:52 
Re: Ada.Strings.Bounded
Ray Blaak <rAYblaaK@[E  2008-04-23 17:09:42 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 0:04:55 CDT 2008.