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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,a094903f87897fa4,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!j4g2000yqa.googlegroups.com!not-for-mail From: Laurie Dillon Newsgroups: comp.lang.ada Subject: SPARK examiner visibility problem Date: Sun, 13 Sep 2009 15:47:41 -0700 (PDT) Organization: http://groups.google.com Message-ID: <8d72d20b-489b-4494-9b13-1b00ee902850@j4g2000yqa.googlegroups.com> NNTP-Posting-Host: 24.11.160.6 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1252882061 4168 127.0.0.1 (13 Sep 2009 22:47:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 13 Sep 2009 22:47:41 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j4g2000yqa.googlegroups.com; posting-host=24.11.160.6; posting-account=1Qf4bgoAAACCVzZU3e8q6VmsNa4hU5j_ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8315 Date: 2009-09-13T15:47:41-07:00 List-Id: I am having trouble with a toy example of encapsulating IO for a SPARK program. My example seems to be consistent with the Spark_IO example in the Barnes book. I have the following package spec: ------------------------------------------------------------------------------------- with Ada.Text_IO; package Std_IO -- encapsulates IO to and from standard input and standard output --# own stdin: Istream_Type; --# stdout: Ostream_Type; --# initializes stdin, --# stdout; is --# type Istream_Type is abstract; --# type Ostream_Type is abstract; procedure New_Line; -- output a new line to stdout --# global in out stdout; --# derives stdout from *; procedure Put_Line (Item : in String); -- output a string followed by a carriage return to stdout --# global in out stdout; --# derives stdout from *, Item; procedure Put_Integer (Item : in Integer); -- output an integer to stdout --# global in out stdout; --# derives stdout from *, Item; procedure Get_Integer (Item : out Integer; OK : out Boolean); -- input an integer from stdin --# global in stdin; --# derives Item, OK from stdin; end Std_IO; ---------------------------------------------------------------------------------------------------------- The examiner has no problem with this package (the body carries a #hide Std_IO annotation). But when I try to examine a package spec (or body) that inherits Std_IO, I get semantic errors at every reference to Std_IO.stdin and Std_IO.stdout. For example, consider the following spec: ----------------------------------------------------------------------------------- --# inherit Std_IO; package MyGps --# own home; is type Location is record x : Integer; y : Integer; end record; procedure MoveTo (theLoc : in Location); -- moves home to the given location --# global out home; --# derives home from theLoc; function Distance (theLoc : Location) return Integer; -- returns the (taxi) distance from home to the given location --# global home; procedure GetLocation (theLoc : out Location); -- prompts user for theLoc --# derives theLoc from Std_IO.stdin; end MyGps; --------------------------------------------------------------------------------------------- Examiner report says: Unit name: MyGps Unit type: package specification Unit has been analysed, any errors are listed below. 1 error(s) or warning(s) Line 23 --# derives theLoc from Std_IO.stdin; ^1 *** ( 1) Semantic Error :752: The identifier Std_IO.stdin is either undeclared or not visible at this point. This identifier must appear in a preceding legal global annotation or formal parameter list. ------------------------------------------------------------------------------------- I thought the own declaration for stdin in the spec of Spark_IO should qualify as "a preceding legal global annotation". What am I missing here? Analysis of the body of myGps gives similar errors. For example: Unit name: MyGps Unit type: package body Unit has been analysed, any errors are listed below. 14 error(s) or warning(s) Line 35 Std_IO.Put_Line (Item => "Enter x-coordinate of location : "); ^1,2 *** ( 1) Semantic Error : 25: The identifier Std_IO.stdout (imported by called subprogram) is not visible at this point. *** ( 2) Semantic Error : 24: The identifier Std_IO.stdout (exported by called subprogram) is not visible at this point. -------------------------------------------------------------------------------------- Note that Std_IO.Put_Line is visible, as it should be. Any insights or explanation for what I'm doing wrong in this example will be greatly appreciated! Thanks, Laurie