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 85 of 109 Topic 5630 of 5827
Post > Topic >>

Re: Ada.Strings.Bounded

by Adam Beneschan <adam@[EMAIL PROTECTED] > Apr 21, 2008 at 05:49 PM

On Apr 21, 5:19 pm, Eric Hughes <eric....@[EMAIL PROTECTED]
> wrote:

> OK.  Somehow I had missed the fact that Ada does overload resolution
> based on assignment context.  So I read up on it in more detail.
> Pardon me if I've missed something in the foregoing.
>
> The overload resolution in the present example, though, doesn't seem
> unique.  Could not "+" resolve to the "+" of root_integer?  It seems
> to pass all of the requirements.  To test this, I wrote the following
> three lines of code and ran them through GNAT:
>     -- (Example A)
>     Z0 : constant := Integer'Last - 1 ;
>     type Z is range 0 .. Z0 ;
>     B : constant Z := ( Z0 + 1 ) - 1 ;
> GNAT compiled it without a problem and it ran without error.  The
> following program, however, did neither:
>     -- (Example B)
>     Z0 : constant := Integer'Last - 1 ;
>     type Z is range 0 .. Z0 ;
>     C : constant Z := Z0 + 1 ;
> GNAT gave a warning that a constraint error would be raised and indeed
> running it raised one.  Now I raise the upper bound by one:
>     -- (Example C)
>     Z0 : constant := Integer'Last ;
>     type Z is range 0 .. Z0 ;
>     B : constant Z := ( Z0 + 1 ) - 1 ;
> GNAT compiles this one fine and runs fine, just like Example A.
>     -- (Example D)
>     Z0 : constant := Integer'Last ;
>     type Z is range 0 .. Z0 ;
>     C : constant Z := Z0 + 1 ;
> GNAT says "static expression fails Constraint_Check" and does not
> compile.  Let's raise the upper bound one last time:
>     -- (Example E)
>     Z0 : constant := Integer'Last + 1 ;
>     type Z is range 0 .. Z0 ;
>     B : constant Z := ( Z0 + 1 ) - 1 ;
> Just fine, as usual.
>     -- (Example F)
>     Z0 : constant := Integer'Last + 1 ;
>     type Z is range 0 .. Z0 ;
>     C : constant Z := Z0 + 1 ;
> GNAT gives the same warning as example B.
>
> As an aside, GNAT is clearly doing something odd.  Of the three
> declarations of "C", you have two warnings and one error, not the
> same.  I'm not even sure that's a defect.
>
> The real point, though, is that it just can't be true that the
> addition and subtraction in examples A and C are those of type Z.  If
> this were true, the expression
>     ( Z0 + 1 ) - 1
> should translate to something like this:
>     Z_subtract( Z_add( Z0, 1 ), 1 )
> If that were the case, then the Z_add expression should raise a
> constraint error.  It doesn't.  Maybe this is a GNAT defect.  It seems
> just as likely that overload resolution is taking the addition and
> subtraction of root_integer.

See 4.9(33).  I'm not sure it applies in this case, though, since the
root_integer operations will be preferred (see below).  But note that
this compiles and will not cause Constraint_Error to be raised:

   A1 : constant Integer := Integer'Last;
   A2 : constant Integer := (A1 + 1) - 1;


> And then I had an inspiration:
>     -- (Example G)
>     Z0 : constant := Long_Long_Integer'Last ;
>     type Z is range 0 .. Z0 ;
>     B : constant Z := ( Z0 + 1 ) - 1 ;
>     -- (Example H)
>     Z0 : constant := Long_Long_Integer'Last + 1 ;
>     type Z is range 0 .. Z0 ;
>     B : constant Z := ( Z0 + 1 ) - 1 ;
> Now we've hit the GNAT implementation limit.  Example H, finally,
> fails to compile because "integer type definition bounds out of
> range".  (I don't like this message because it's not clear that an
> internal limit has been exceeded.)  Example G, however, compiles and
> runs just fine.  Example G shows that, at least in this example, it's
> doing arithmetic on universal_integer, because there's no other type
> internally that it could be using.
>
> > Choosing which function to call nondeterministically seems
> > like an Obviously Bad Idea, to me, so perhaps I don't understand
> > what you mean.
>
> All the above examples seem to indicate that GNAT, at least, is
> resolving overloaded addition operators.  The overload is between the
> declared type, root_integer (or something like it), and possibly even
> universal_integer.  With other types, ones where there is no universal
> type, this would be an illegal ambiguity.  So it seems that GNAT is
> nondeterministically resolving them.

There's nothing nondeterministic about this.  See 8.6(29).

I can't follow your argument so I have no idea whether these points
affect it or not.  But you do seem to have made at least a couple
mistakes about the language.

                                 -- Adam
 




 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:17:08 CDT 2008.