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,64691254fcf844dd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!news.glorb.com!proxad.net!193.252.118.146.MISMATCH!news.wanadoo.fr!news.wanadoo.fr!not-for-mail From: Jean-Baptiste CAMPESATO Organization: a2lf - Association pour le Logiciel Libre Francophone Subject: Re: Translate from C Date: Sun, 10 Apr 2005 09:47:13 +0200 User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table) Message-Id: Newsgroups: comp.lang.ada References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit NNTP-Posting-Date: 10 Apr 2005 09:44:59 CEST NNTP-Posting-Host: 83.200.103.132 X-Trace: 1113119099 news.wanadoo.fr 19320 83.200.103.132:40182 X-Complaints-To: abuse@wanadoo.fr Xref: g2news1.google.com comp.lang.ada:10372 Date: 2005-04-10T09:44:59+02:00 List-Id: Le Sun, 10 Apr 2005 01:36:45 +0000, Dennis Lee Bieber a �crit�: > On Sat, 09 Apr 2005 21:30:30 +0200, Jean-Baptiste CAMPESATO > declaimed the following in comp.lang.ada: > >> Hello, >> I've this code in C : http://www.a2lf.org/util.c >> and i want to translate it in Ada; >> A friend tried : >> procedure Copy >> (Source : Address; >> Destination : Address; >> Bytes : Natural) >> is >> S : String (1 .. Bytes); >> D : String (1 .. Bytes); >> for S'Address use Source; >> for D'Address use Destination; >> begin >> for I in S'Range loop >> D (I) := S (I); >> end loop; >> end Copy; >> >> Do you think it's Ok ? > > Probably not... You don't supply the type definition for > "Address", nor an example of how the calling program will supply it... > After all, there is no generic "pointer to anything" in Ada (that I know > of, anyway)... Access types still are defined as pointers to /something/ > that the compiler can check. > > Ignoring the problems of calling and passing pointers, the > actual processing is probably not needed... What's wrong with just: > > D := S; > > and letting the compiler create the loop. After all, it already knows > that D and S are both strings of a known size. > > The better question is: WHY do you need this procedure? What do > you expect to gain from it that you can't do with the language as-is? Or > even more to the point, do without even using "pointer" semantics? Ok :) Thanks