comp.lang.ada
 help / color / mirror / Atom feed
From: echancrure@gmail.com
Subject: worrying behaviour
Date: Fri, 2 May 2008 08:26:14 -0700 (PDT)
Date: 2008-05-02T08:26:14-07:00	[thread overview]
Message-ID: <af1298c2-fa66-4e25-b387-68b9bb02e55b@m3g2000hsc.googlegroups.com> (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.



             reply	other threads:[~2008-05-02 15:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-02 15:26 echancrure [this message]
2008-05-02 15:54 ` worrying behaviour 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
replies disabled

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