Talk About Network



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 > worrying behavi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 5681 of 5697
Post > Topic >>

worrying behaviour

by echancrure@[EMAIL PROTECTED] May 2, 2008 at 08:26 AM

After the discussion on static expressions etc.

I came up against this problem which I thought was initially related
to it but probably not.

let's say I have:

with Ada.Text_IO;  use Ada.Text_IO;
with ints;
procedure static is
   function "-"(L, R : ints.My_Int) return ints.My_int renames
ints."-";
   function "-"(L : ints.My_Int) return ints.My_int renames ints."-";
   Y : constant ints.My_int := -1;
   Z : constant ints.My_int := 1-1;
begin
   Put_Line (ints.My_Int'Image (Y) & ints.My_Int'Image (Z));
end static;

and

package ints
is
  type My_Int is range -100..100;
  function "-"   (L, R : My_Int) return My_int;
end ints;

package body ints
is
  function "-" (L, R : My_Int) return My_Int
  is
  begin
    return 42;
  end "-";
end ints;

So basically, I have forgotten to define unary "-" in the the ints
package.

gnat does not complain and the .exe returns '-1 42' as would be
expected without the unary - rename.

Here however I have renamed the unary - to something that does not
exist.

Surely an error should be generated here. Otherwise this is very
dangerous behaviour.

Please enlight me.




 6 Posts in Topic:
worrying behaviour
echancrure@[EMAIL PROTECT  2008-05-02 08:26:14 
Re: worrying behaviour
Adam Beneschan <adam@[  2008-05-02 08:54:01 
Re: worrying behaviour
"Randy Brukardt"  2008-05-02 20:15:14 
Re: worrying behaviour
echancrure@[EMAIL PROTECT  2008-05-02 10:41:01 
Re: worrying behaviour
Adam Beneschan <adam@[  2008-05-02 11:31:31 
Re: worrying behaviour
Adam Beneschan <adam@[  2008-05-02 19:04:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Tue May 13 16:53:45 CDT 2008.