comp.lang.ada
 help / color / mirror / Atom feed
* worrying behaviour
@ 2008-05-02 15:26 echancrure
  2008-05-02 15:54 ` Adam Beneschan
  0 siblings, 1 reply; 6+ messages in thread
From: echancrure @ 2008-05-02 15:26 UTC (permalink / raw)


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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-05-03  2:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-02 15:26 worrying behaviour echancrure
2008-05-02 15:54 ` Adam Beneschan
2008-05-02 17:41   ` echancrure
2008-05-02 18:31     ` Adam Beneschan
2008-05-03  1:15   ` Randy Brukardt
2008-05-03  2:04     ` Adam Beneschan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox