From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9ce095aba33fe8d0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Negative float problem Date: 26 Oct 2005 16:42:43 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1130351574.313991.229420@g14g2000cwa.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1130359363 3298 192.74.137.71 (26 Oct 2005 20:42:43 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 26 Oct 2005 20:42:43 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:5965 Date: 2005-10-26T16:42:43-04:00 List-Id: "Luke" writes: > Hi > > If I have two files: > file1: > package file1 is > > type My_Float is digits 6; > > end file1; > > and file2: > with file1; > > procedure file2 is > X : file1.My_Float := -1.0; > begin > X := 1.0; > end file2; > > and do gnatmake file2.adb i get the following error: > file2.adb:4:31: operator for type "My_Float" defined at file1.ads:3 is > not directly visible > file2.adb:4:31: use clause would make operation legal > > There are two solutions: > 1) add a use type as sugested > 2) Change line 4 to: X : file1.My_Float := file1.My_Float(-1.0); > > If 2 works then why doesnt the original? The same is true for +1.0. > Is this a fault with gcc? No. It's a fault with the Ada language. ;-) GNAT is implementing the language correctly, here. Sam Tardieu explained why the second one works, but not the original. But I suggest using the first solution. Really, the "use type" semantics ought to be turned on by default -- you shouldn't have to say anything special to use the "-" operator. After all, you don't have to say anything special to use "1.0" or ":=" on this type! - Bob