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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7722b78486dfd336 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!freenix!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Lionel.DRAGHI@fr.thalesgroup.com Newsgroups: comp.lang.ada Subject: RE: Zero_Fill pragma, other proposition Date: Wed, 21 Jul 2004 15:17:55 +0200 Organization: Cuivre, Argent, Or Message-ID: NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: melchior.cuivre.fr.eu.org 1090415958 80657 212.85.156.195 (21 Jul 2004 13:19:18 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Wed, 21 Jul 2004 13:19:18 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: X-Mailer: Internet Mail Service (5.5.2653.19) X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: g2news1.google.com comp.lang.ada:2317 Date: 2004-07-21T15:17:55+02:00 | -----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