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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9a1fb7a9d3453036,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!q75g2000hsh.googlegroups.com!not-for-mail From: pilarp@poczta.onet.pl Newsgroups: comp.lang.ada Subject: generic package, can't find an error Date: 12 May 2007 06:50:17 -0700 Organization: http://groups.google.com Message-ID: <1178977817.583151.234370@q75g2000hsh.googlegroups.com> NNTP-Posting-Host: 62.141.244.37 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" X-Trace: posting.google.com 1178977818 15198 127.0.0.1 (12 May 2007 13:50:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 12 May 2007 13:50:18 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: q75g2000hsh.googlegroups.com; posting-host=62.141.244.37; posting-account=AO-TDQ0AAABOS8bv4ZLS79jtzJ198P_u Xref: g2news1.google.com comp.lang.ada:15779 Date: 2007-05-12T06:50:17-07:00 List-Id: I wrote a small program using a generic package, one of its functions (the one posted below, named read_file_text) was supposed to get some elements from a text file and write them on a standard output. In the test program the package was instantiated with float type. The remaining procedures and functions work properly, so I excluded them from the source code of my program which you can see below. The source code is included in 3 separate files: arrays.ads (package specification), arrays.adb (package body) and test_arrays.adb (test program using the package). While I compile arrays.ads and arrays.adb succesfully, I get the following compiler error when I try to compile test_arrays.adb: "No visible program matches the specification for "Get" ". Please look at the code and tell me what is wrong. arrays.ads: with Ada.Text_Io; use ada.text_io; generic type element is private; with procedure get(f:in file_type; o: out element) is <>; PACKAGE arrays IS TYPE arr IS ARRAY(Positive RANGE<>) OF element; FUNCTION Read_File_Text(File:IN String) RETURN arr; END arrays; arrays.adb: package body arrays is FUNCTION Read_File_Text(File:IN String) RETURN arr IS F:File_Type; el:element; i:natural:=0; BEGIN BEGIN Open(F,In_File,File); EXCEPTION WHEN Name_Error=> DECLARE a:arr(1..0); BEGIN RETURN a; END; END; WHILE NOT (End_Of_File(F)) LOOP Get(F,el); skip_line(f); I:=I+1; END LOOP; reset(f,in_file); DECLARE a:arr(1..I); BEGIN FOR J IN 1..I LOOP get(f,a(i)); END LOOP; Close(F); RETURN a; END; END read_file_Text; test_arrays.adb: with ada.text_io,ada.float_text_io,arrays; use ada.text_io,ada.float_text_io; procedure test_arrays is N:Natural; file:string(1..10):=(others=>' '); package arrays_float is new arrays(float,get); use arrays_float; begin put("Which file do you want to read?:"); get_line(file,n); skip_line; for i in read_file_text(file)'range loop put(read_file_text(file)(i),0,2,0); put(" "); end loop; end test_arrays;