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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.11.194 with SMTP id 42mr7367366yhx.19.1415337698117; Thu, 06 Nov 2014 21:21:38 -0800 (PST) X-Received: by 10.50.73.98 with SMTP id k2mr14479igv.8.1415337697955; Thu, 06 Nov 2014 21:21:37 -0800 (PST) Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!u7no3025707qaz.1!news-out.google.com!ks2ni13482igb.0!nntp.google.com!h15no7298356igd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 6 Nov 2014 21:21:37 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=203.180.0.36; posting-account=4fWUrwoAAADVRjV2pCvHYc7D992ABDos NNTP-Posting-Host: 203.180.0.36 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <520f8f3d-b345-4ef8-ac41-ead78edde92a@googlegroups.com> Subject: Can .ads be compiled alone? From: moixa Injection-Date: Fri, 07 Nov 2014 05:21:38 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.giganews.com comp.lang.ada:190355 Date: 2014-11-06T21:21:37-08:00 List-Id: Newbie question. I have only two files, machinery_1_3.ads [1] and machinery_1_3.adb [2], in some directory, when I `gnat compile machinery_1_3.ads`, it told me compile error, (but no further information). A stackoverflow post[3] said that it's a good practice to separate compile the spec and the body, so, why I cannot compile my .ads? --------------------------- [3] http://stackoverflow.com/questions/9921794/error-when-compiling-spec-files --------------------------- [1] machinery_1_3.ads package Machinery_1_3 is -- 1 Package specification; requires body type Machine is private; -- 2 Specifies the visible part of the data type; procedure Turn_On (M : in out Machine); -- 3 procedure specification procedure Turn_Off (M : in out Machine); -- 4 procedure specification function Is_On (M : in Machine) return Boolean; -- 5 function specification private -- 6 private part hidden from a client of contract type Machine is record -- 7 full definition of the publicly declared type Turned_On : Boolean := False; -- 8 component of the type; OOP attribute end record; -- 9 scope terminator for the component end Machinery_1_3; -- 10 scope terminator for the specification --------------------------- [2] machinery_1_3.adb package body Machinery_1_3 is -- 1 Package body; implements specification declarations procedure Turn_On (M : in out Machine) is -- 2 Repeat procedure specification; compiler checks this begin -- 3 Starts algorithmic section of procedure M.Turned_ON := True; -- 4 Simple assignment statement of boolean value end Turn_On; -- 5 Procedure scope terminator is required procedure Turn_Off (M : in out Machine) is -- 6 Must match profile in specification begin -- 7 Algorithms between begin and end M.Turned_On := False; -- 8 M.Turned called dot notation end Turn_Off; -- 9 Name is optional but end is required function Is_On (M : in Machine) return Boolean is -- 10 In mode is like a constant; it may begin -- 11 not be on left side of assignment return M.Turned_On; -- 12 return statement required of every function end Is_On; -- 13 Scope terminator for function end Machinery_1_3; -- 14 End of all declarations for this package