comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: AI12-0218: What is the portable representation clause for processing IETF packets on little-endian machines?
Date: Fri, 11 May 2018 11:40:23 +0200
Date: 2018-05-11T11:40:23+02:00	[thread overview]
Message-ID: <pd3oe7$ro9$1@gioia.aioe.org> (raw)
In-Reply-To: 2821b8e0-2c64-4621-b65e-337027fc121e@googlegroups.com

On 10/05/2018 22:06, Dan'l Miller wrote:

> LoL!!  Oh, do tell why a representation clause on an IETF packet's header layout is “useless”.

Because the language of representation clauses is too weak to handle 
layouts. One could design and integrate a full blown data-definition 
language (with conditional and looping constructs) into Ada but that 
would be a gigantic waste of time. It just does not make sense. The 
result of this are data types one cannot use effectively. To name a few 
examples from real life:

1. Integer types with reserved bit-patterns for exceptional states. E.g. 
16#FFFF#, 16#FFFE#, 16#FFFD# are not numbers but states of the hardware.

2. Non-contiguous integers. E.g. low-order 16 bits in one word, 
high-order 8 bits in a word two words ahead.

3. Middle-endian numbers.

4. Non-2's complement signed integer numbers

Therefore the programmer must copy them into machine-friendly Ada native 
types anyway. It is simpler to do this right while encoding/decoding the 
packet.

Then there is error handling and sanity checks issues which 
representation clauses do not do. So the programmer will get some 
rubbish in the memory *already* interpreted as a valid value of Ada 
type. Read - the type system breach. He must then re-check everything 
inside by re-scanning the I/O buffer one more time, because X'Valid is 
no help here.

Furthermore, representation clauses require complete packet or its parts 
read into the buffer or written away. Communication, e.g. asynchronous 
I/O just does not work this way. The application must deal with data 
chunks of almost arbitrary length. Representation clauses would require 
additional assembling/disassembling of data into chunks and thus extra 
copying.

Ergo. It works for a few cases on paper. In real life it is simpler, 
faster, safer and cleaner not to use representation clauses at all.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  parent reply	other threads:[~2018-05-11  9:40 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-10 17:45 AI12-0218: What is the portable representation clause for processing IETF packets on little-endian machines? Dan'l Miller
2018-05-10 19:24 ` Dan'l Miller
2018-05-10 20:32   ` Paul Rubin
2018-05-10 22:24     ` Dan'l Miller
2018-05-10 22:44       ` Niklas Holsti
2018-05-10 23:14         ` Paul Rubin
2018-05-11  2:38         ` Dan'l Miller
2018-05-11  7:55           ` Simon Wright
2018-05-11 12:11             ` Lucretia
2018-05-11 13:49               ` Simon Wright
2018-05-11 16:11                 ` Jeffrey R. Carter
2018-05-11 16:48                   ` Simon Wright
2018-05-11 19:08                     ` Jeffrey R. Carter
2018-05-11 21:39                       ` Simon Wright
2018-05-11 21:56                         ` Jeffrey R. Carter
2018-05-12  7:08                           ` Simon Wright
2018-05-12  7:53                             ` Jeffrey R. Carter
2018-05-14 22:43                             ` Randy Brukardt
2018-05-11 13:46             ` Simon Wright
2018-05-11 22:12           ` Randy Brukardt
2018-05-12 10:33             ` Björn Lundin
2018-05-12 13:08               ` Simon Wright
2018-05-12 14:21                 ` Björn Lundin
2018-05-10 23:07       ` Paul Rubin
2018-05-11  0:14         ` Dan'l Miller
2018-05-11  0:30           ` Paul Rubin
2018-05-11  0:50             ` Dan'l Miller
2018-05-11  1:34               ` Paul Rubin
2018-05-11  2:11                 ` Dan'l Miller
2018-05-11 22:32                   ` Randy Brukardt
2018-05-11  8:02         ` Simon Wright
2018-05-11 22:14         ` Randy Brukardt
2018-05-10 19:28 ` Simon Wright
2018-05-10 22:40   ` Randy Brukardt
2018-05-10 22:50     ` Dan'l Miller
2018-05-11 22:00       ` Randy Brukardt
2018-05-12  1:15         ` Paul Rubin
2018-05-14 22:54           ` Randy Brukardt
2018-05-15  0:43             ` Paul Rubin
2018-05-15 21:39               ` Randy Brukardt
2018-05-15  0:44             ` Dennis Lee Bieber
2018-05-11  8:09     ` Simon Wright
2018-05-10 19:34 ` Dmitry A. Kazakov
2018-05-10 20:06   ` Dan'l Miller
2018-05-10 22:44     ` Paul Rubin
2018-05-10 22:50     ` Randy Brukardt
2018-05-11  9:40       ` Niklas Holsti
2018-05-11 11:40         ` Dan'l Miller
2018-05-11 20:16           ` Niklas Holsti
2018-05-11  9:40     ` Dmitry A. Kazakov [this message]
2018-05-11 14:21 ` AdaMagica
2018-05-26 16:15 ` Dan'l Miller
2018-05-26 19:02   ` AdaMagica
2018-05-26 21:01     ` Dan'l Miller
2018-05-27 14:58       ` AdaMagica
2018-05-27 18:03         ` Simon Wright
2018-05-29 22:17           ` Randy Brukardt
2018-05-30  6:39             ` Simon Wright
2018-05-30  7:25               ` Dmitry A. Kazakov
2018-05-30 15:01                 ` Simon Wright
2018-05-30 15:59                   ` Dan'l Miller
2018-05-30 19:38               ` Randy Brukardt
2018-05-27 18:04         ` Dan'l Miller
replies disabled

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