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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,26aa6d7095c151 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-18 02:45:35 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!news-FFM2.ecrc.net!newsfeed1.sbs.de!news.mch.sbs.de!not-for-mail From: Bernd.Specht@gmx.com (Bernd Specht) Newsgroups: comp.lang.ada Subject: Re: Porting from Modula-2 to Ada Date: Fri, 18 Oct 2002 09:45:34 +0000 (UTC) Organization: No company Message-ID: References: <3DAFC542.152C0EE0@lml.ls.fi.upm.es> NNTP-Posting-Host: 139.21.122.158 X-Trace: news.mch.sbs.de 1034934334 20144 139.21.122.158 (18 Oct 2002 09:45:34 GMT) X-Complaints-To: abuse@siemens.de NNTP-Posting-Date: Fri, 18 Oct 2002 09:45:34 +0000 (UTC) User-Agent: Xnews/4.05.03 Xref: archiver1.google.com comp.lang.ada:29894 Date: 2002-10-18T09:45:34+00:00 List-Id: Manuel Collado wrote in news:3DAFC542.152C0EE0 @lml.ls.fi.upm.es: > We are porting some legacy Modula-2/C code to Ada. The code uses > low-level facilities from Modula-2 and C. We would like to port it to > clean Ada, without interfacing to C code. In addition we would like to > keep the old interface unchanged (if possible). > > Al present we are looking for ways to manage memory and binary files as > arrays of bytes. The trouble is that Modula-2 allows the use of relaxed > ARRAY OF BYTE subprogram formal parameters, that are compatible with > actual parameters of any type. Example: > > PROCEDURE Xxx( raw: ARRAY OF BYTE ); > ... > BEGIN > FOR k := 0 TO HIGH(raw) DO > ... raw[k] .... > END > END Xxx; > > Num: INTEGER; > ... > Xxx( Num ); > ... > > > So far, my only porting scheme is to replace ARRAY OF BYTE parameters by > the pair (address, size), as follows: > > procedure Xxx (Raw_Address: System.Address; Raw_Size: Integer) ... > > Num: Integer; > ... > Xxx (Num'Address, Num'Size); > ... > > But this requires recoding every call to the procedure. Is there another > way to pass raw data without having to recode every call? > > Thanks. Would it be an idea not to substitute the procedure by _one_ other procedure but with a set of overloaded procedures? procedure Xxx (raw : Integer_Field) is ... procedure Xxx (raw : Character_Field) is ... procedure Xxx (raw : Float_Field) is ... where type Integer_Field is array (Integer range <>) of Integer; type Character_Field is array (Integer range <>) of Character; type Float_Field is array (Integer range <>) of Float;