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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,26aa6d7095c151 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-18 03:55:33 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed2.news.rcn.net!rcn!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc51.ops.asp.att.net.POSTED!not-for-mail From: "Jeffrey Creem" Newsgroups: comp.lang.ada References: <3DAFC542.152C0EE0@lml.ls.fi.upm.es> Subject: Re: Porting from Modula-2 to Ada X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: NNTP-Posting-Host: 66.31.5.146 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc51.ops.asp.att.net 1034938533 66.31.5.146 (Fri, 18 Oct 2002 10:55:33 GMT) NNTP-Posting-Date: Fri, 18 Oct 2002 10:55:33 GMT Organization: AT&T Broadband Date: Fri, 18 Oct 2002 10:55:33 GMT Xref: archiver1.google.com comp.lang.ada:29897 Date: 2002-10-18T10:55:33+00:00 List-Id: I'd probably go with a generic that can be instantiated for each "thing" you want to write or use a ugly 'address and 'size based approach that does not require generics. Note that if you take the generic route it is a little more work but somewhat cleaner. When I have done this I tend to make the generic formal parameter be private instead of limited private. There are times when limited might be right but almost any time someone makes something limited, the in memory representation one would get via the type is somewhat bogus. Also, it is worth checking in the generic body that the 'size of the type is a multiple of the 'size of the storage element (or whatever type you use to write to the file) "Lutz Donnerhacke" wrote in message news:slrnaqvosa.nv.lutz@taranis.iks-jena.de... > * Bernd Specht wrote: > > 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 ... > > And now use generics: > > generic > type T(<>) is limited private; > procedure Xxx (data : T); > > procedure Xxx (data : T) is > use System.Storage_Elements; > raw : Storage_Array (Storage_Offset'First .. > Storage_Offset'First + (data'Size + Storage_Unit - 1) / Storage_Unit); > pragma Import (Ada, raw); > for raw'Address use data'Address; > begin > ...