comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Baptiste CAMPESATO <camje_lemon@a2lf.org>
Subject: Re: Translate from C
Date: Sun, 10 Apr 2005 09:47:13 +0200
Date: 2005-04-10T09:44:59+02:00	[thread overview]
Message-ID: <pan.2005.04.10.07.47.12.224610@a2lf.org> (raw)
In-Reply-To: gkvg51de5t83scllh0sp7go8nmcfe3ede9@4ax.com

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
> <camje_lemon@a2lf.org> 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



  parent reply	other threads:[~2005-04-10  7:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-09 19:30 Translate from C Jean-Baptiste CAMPESATO
2005-04-09 20:54 ` tmoran
     [not found] ` <gkvg51de5t83scllh0sp7go8nmcfe3ede9@4ax.com>
2005-04-10  7:47   ` Jean-Baptiste CAMPESATO [this message]
2005-04-11 13:39 ` Steve
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox