From: anon@anon.org (anon)
Subject: Re: Adding offset to 'Address
Date: Fri, 19 Sep 2008 09:25:06 GMT
Date: 2008-09-19T09:25:06+00:00 [thread overview]
Message-ID: <SdKAk.227399$102.90697@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: gavfnq$kgp$1@jacob-sparre.dk
Well have you looked at Ada-2005 language code, lately. It seams that in every
upgradde that the maintainer ( Adacore ) are replacing Ada defined type with
System.Address, more and more.
But in relooking at this thread maybe the person wants the next version of
Ada to have the following type of variable attribute for 'Address.
Variable'Address ( Offset )
Now, for this thread:
Count : Natural ;
-- Count is set to the largest index that you may need
function Address_Offset ( Source : in System.Address ;
Index : Natural )
return Array_Element_Type ;
type Storage_Array is array ( 0..Count )
of aliased Array_Element_Type ;
Array_Source : Storage_Array ;
for Array_Source'Address use Source ;
begin
if Index >= 0 and Index <= Count then
return Array_Source ( Index ) ;
else
raise Storage_Error ;
end if ;
end ;
This is based on the Memcy package.
In <gavfnq$kgp$1@jacob-sparre.dk>, "Randy Brukardt" <randy@rrsoftware.com> writes:
>"Kim Rostgaard Christensen" <krc@greenpc.dk> wrote in message
>news:gaqhs6$690$1@jacob-sparre.dk...
>> tmoran@acm.org wrote:
>>>> Raw_Bytes : access Unsigned_Char
>>>> for Ethernet_Header'Address use Raw_Bytes.all'Address;
>>>>
>>>> and additionally need something like:
>>>> for IP_Packet'Address use Raw_Bytes.all'Address + Ethernet_Header'Size;
>>>
>>> It's not clear to me exactly what problem you are trying to get past.
>>
>> The problem was basically to perform arithmethics on system addresses
>
>No, that's a (bad) solution to some problem, not a problem by itself. The
>problem seems to be how to access the data bytes without accessing the
>header, and Tom suggests a good solution for that. (We use versions of it in
>Claw.)
>
>IMHO, the use of Address in Ada 95 or newer code (other than to specify raw,
>absolute machine addresses) is never necessary and represents bad
>programming. I see it fairly often here, and it makes me ill. I much prefer
>general access types and possibly Unchecked_Conversions, because you lose
>much less strong typing that way (and the code is better without the need
>for heroic efforts on the part of the compiler).
>
> Randy.
>
>
> Randy.
>
>
next prev parent reply other threads:[~2008-09-19 9:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-12 8:35 Adding offset to 'Address Kim Rostgaard Christensen
2008-09-12 9:47 ` Georg Bauhaus
2008-09-12 10:17 ` Kim Rostgaard Christensen
2008-09-12 11:18 ` petter_fryklund
2008-09-12 15:23 ` Adam Beneschan
2008-09-12 21:40 ` Robert A Duff
2008-09-13 0:37 ` Adam Beneschan
2008-09-13 6:21 ` tmoran
2008-09-17 9:15 ` Kim Rostgaard Christensen
2008-09-19 6:09 ` Randy Brukardt
2008-09-19 9:25 ` anon [this message]
2008-09-13 10:18 ` Björn
2008-09-17 9:18 ` Kim Rostgaard Christensen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox