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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c548fcf2944e2c9b X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: What's wrong with my code? Date: Mon, 28 Apr 2008 17:18:31 +0200 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <5a3b83ab-c9eb-448d-8e01-093df11bd3d2@b1g2000hsg.googlegroups.com> Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: tigger.scc.uni-weimar.de 1209396416 21266 141.54.178.228 (28 Apr 2008 15:26:56 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Mon, 28 Apr 2008 15:26:56 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: <5a3b83ab-c9eb-448d-8e01-093df11bd3d2@b1g2000hsg.googlegroups.com> Xref: g2news1.google.com comp.lang.ada:21099 Date: 2008-04-28T17:18:31+02:00 List-Id: On Mon, 28 Apr 2008, amal.alphonse@gmail.com wrote: > Sorry if I'm posting in the wrong forum. You are perfectly right here. > with Ada.Text_IO, Ada.Integer_Text_IO; > with SelectionP; > procedure SelectionPUser is Replace the following line > package IntSelectionP is new SelectionP(Integer, Ada.Text_IO.Put); by procedure Put_Int(I: Integer) is begin Ada.Integer_Text_IO.Put(I); end Put_Int; package Int_SelectionP is new X(Integer, Put_Int); The specification of Put in Ada.Integer_Text_IO is procedure Put(Item : in Num; Width : in Field := Default_Width; Base : in Number_Base := Default_Base); Thanks to the default parameters, you can just write "Ada.Integer_Text_IO.Put(I);" to *call* this procedure Put. But using the same Put as a generic parameter appears to be different ... > begin > Ada.Text_IO.New_Line; > end SelectionPUser; > procedure Print (A: in out My_Array) is Nitpick: this should be procedure Print(A in My_Array) is to conform with the specification. Additional point: Most Ada programmers depreciate identifiers like IntSelectionP, SelectionP, ... but prefer to use underscores: Int_Selection_P, Selection_P. This improves readability and copes well with the case-insensitivity of Ada identifiers. (E.g., for ada Selections and SelectionS are the same, but Selections and Selection_S are different. I currently can't find a better example, but I hope you get the idea.) > Also, is my code correct if my purpose is to use the package to create > arrays of different elements (integer, character, etc) and use the > procedures Find_Min and Sort and Print on them? I guess you are going to compare your elements? Then you'll want to specify another generic parameter (in addition to the type Element and the procedure Element_Put), such as function "<"(Left, Right: Element) return Boolean; -- ------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------ Stefan dot Lucks at uni minus weimar dot de ------ I love the taste of Cryptanalysis in the morning! ------