From: Lionel.DRAGHI@fr.thalesgroup.com
To: comp.lang.ada@ada-france.org
Subject: RE: Zero_Fill pragma, other proposition
Date: Wed, 21 Jul 2004 15:17:55 +0200
Date: 2004-07-21T15:17:55+02:00 [thread overview]
Message-ID: <mailman.35.1090415957.416.comp.lang.ada@ada-france.org> (raw)
| -----Message d'origine-----
...
| > type Message is record
| > Id : Message_Id;
| > Data : Byte_Stream;
| > end record;
| >
| > for Message use record
| > Id at 0 range 0 .. 7;
| > Spare at 0 range 8 .. 15 := 0; --> ADDED
| > Data at 0 range 16 .. 65;
| > end record;
| >
...........................................................
| package P is
| type Message is record
| Id : Message_ID;
| Data : Byte_Stream;
| end record;
|
| -- Primitive operations of Message go here
| private
| type Representation is record
| Id : Message_ID;
| Spare : Eight_Bits;
| Data : Byte_Stream;
| end record;
|
| for Representation use record
| Id at 0 range 0 .. 7;
| Spare at 0 range 8 .. 15;
| Data at 0 range 16 .. 65;
| end record;
|
| function To_Rep (M : in Message) return Representation;
| function To_Message (R : in Representation) return Message;
| end P;
|
|
| package body P is
| function To_Rep (M : in Message) return Representation is
| begin
| return (Id => M.Id, Spare => 0, Data => R.Data);
| end To_Rep;
|
| function To_Message (R : in Representation) return Message is
| begin
| return (Id => R.Id, Data => R.Data);
| end To_Message;
|
| -- Primitive operations of Message convert to
| Representation whenever
| -- interfacing to hardware
| end P;
|
| I realise that your proposal reduces the amount of work required to
| achieve this, but the current language does allow you to do what you
| want.
Yes, and the problem is not so common.
On the other hand:
- even on this small example, there is a big difference in required work
(about 1 line vs 20), and a body is required,
- it betters representation details encapsulation,
- it's not a big deal to implement... OK, I don't know about this, but I
bet!
--
Lionel Draghi
next reply other threads:[~2004-07-21 13:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-21 13:17 Lionel.DRAGHI [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-07-21 16:50 Zero_Fill pragma, other proposition Lionel.DRAGHI
2004-07-21 9:20 Lionel.DRAGHI
2004-07-21 10:09 ` Ludovic Brenta
2004-07-21 15:07 ` Nick Roberts
2004-07-21 19:50 ` Wes Groleau
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox