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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,82bafc3cbf94e0b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-09 12:41:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!newsswitch.lcs.mit.edu!newspump.monmouth.com!newspeer.monmouth.com!colt.net!easynet-quince!easynet.net!teaser.fr!enst.fr!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: Can the main procedure be a generic instance? Date: Sat, 9 Nov 2002 14:39:42 -0600 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1036874462 93156 137.194.161.2 (9 Nov 2002 20:41:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sat, 9 Nov 2002 20:41:02 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Original-Cc: steved94@attbi.com Xref: archiver1.google.com comp.lang.ada:30670 Date: 2002-11-09T14:39:42-06:00 The answer to your question is "yes." There is no need to wrap a lone procedure in a package. Just declare a generic library procedure and instantiate it like this: -- gen_main.ads -- with Ada.Text_IO; generic Number_Of_Times : Integer; procedure Gen_Main; -- gen_main.adb -- with Ada.Text_IO; procedure Gen_Main is begin for Count in 1 .. Number_Of_Times loop Ada.Text_IO.Put_Line ("Count = " & Integer'Image (Count)); end loop; end Gen_Main; -- main.ads -- with gen_main; procedure main is new gen_Main (10); Since the instantiation is a procedure specification, GNAT requires the .ads extension if following its default file naming rules. ----- Original Message ----- From: "SteveD" Newsgroups: comp.lang.ada To: Sent: November 09, 2002 11:54 AM Subject: Can the main procedure be a generic instance? > I have defined a generic package gen_main as follows: > > ---------- File: gen_main.ads ---------- > with ada.Text_io; > package Gen_Main is > > generic > number_of_times : integer; > procedure Gen; > > end Gen_Main; > ---------------------------------------- > > ---------- File: gen_main.adb ---------- > with ada.Text_io; > > package body Gen_Main is > > procedure Gen is > begin > for count in 1 .. Number_of_times loop > Ada.Text_Io.Put_Line( "Count = " & Integer'Image( count ) ); > end loop; > end Gen; > > end Gen_Main; > ---------------------------------------- > > I create an instance of the generic > > ---------- File: main.adb ---------- > with gen_main; > procedure main is new gen_Main.Gen( 10 ); > ----------------------------------- > > This program builds and runs under ObjectAda 7.2 as expected. > Using Gnat 3.14p, I get the error: > > D:\>gnatmake -v Main > > GNATMAKE 3.14p (20010503) Copyright 1995-2001 Free Software Foundation, > Inc. > "main.ali" being checked ... > -> "main.ali" missing. > gcc -c main.adb > main.adb:2:11: warning: file name does not match unit name, should be > "main.ads" > > main.adb:2:11: generic instantiation for "main" does not allow a body > main.adb:2:11: remove incorrect body in file "main.adb" > End of compilation > gnatmake: "main.adb" compilation error > > > Should this work? > > SteveD > > > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada > >