comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Using representation clauses in networking software
Date: Sun, 15 Aug 2010 19:58:11 +0200
Date: 2010-08-15T19:58:08+02:00	[thread overview]
Message-ID: <1uzfyshtk9wpq.1ft0ehpgbw60k.dlg@40tude.net> (raw)
In-Reply-To: op.vhhm9desxmjfy8@garhos

On Sun, 15 Aug 2010 18:40:15 +0200, Yannick Duch�ne (Hibou57) wrote:

> Le Sun, 15 Aug 2010 18:10:08 +0200, Dmitry A. Kazakov  
> <mailbox@dmitry-kazakov.de> a �crit:
>>> Would it make sense to deprecate them?
>>
>> Maybe, especially because they do not allow writing portable programs
>> anyway.
> How do you handle this then ?

Dynamically:

   Value :=  Unsigned_16 (Buffer (Index)) * 256 +
      Unsigned_16 (Buffer (Index + 1));
   Index := Index + 2;
   ...
exception
   when Constraint_Error =>
      Raise_Exception (Protocol_Error'Identity, "Malformed telegram at ...

BTW, an ability to handle protocol errors is another good argument against
representation clauses.

> How would interface API as an example ?  
> Formated memory blocks ?

It is usually layered, at least: raw I/O, telegrams, application layer. In
reality it can be more, because modern time protocols themselves are
layered. Many of them are dynamic. You just cannot statically describe all
queries and responses. You ask the device capacities, build query lists,
configure events, start measures, stop measures. It is far too complex for
representation clauses.

> Can you give an example case where this shows to be contradictory with  
> portability ?

When using representation clauses? In order to use them you have two
parameters in the equation: the internal endianness and external
endianness. How can it be statically independent on the former (=portable)?
Well, with conditional expressions of Ada 201X, maybe, it could be possible
to describe. But I don't want to be one to maintain that mess. I'd better
stick to good old means.

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



  reply	other threads:[~2010-08-15 17:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-15 11:33 Using representation clauses in networking software Florian Weimer
2010-08-15 13:44 ` Yannick Duchêne (Hibou57)
2010-08-15 14:32   ` Dmitry A. Kazakov
2010-08-15 14:44     ` Florian Weimer
2010-08-15 15:04       ` Dmitry A. Kazakov
2010-08-15 15:32         ` Florian Weimer
2010-08-15 16:10           ` Dmitry A. Kazakov
2010-08-15 16:40             ` Yannick Duchêne (Hibou57)
2010-08-15 17:58               ` Dmitry A. Kazakov [this message]
2010-08-15 19:11                 ` Shark8
2010-08-15 19:15                 ` Simon Wright
2010-08-15 20:25                   ` Maciej Sobczak
2010-08-15 21:24                     ` Simon Wright
2010-08-16  6:40                     ` Dmitry A. Kazakov
2010-09-04 20:46                     ` Florian Weimer
2010-08-15 15:39         ` Yannick Duchêne (Hibou57)
2010-08-15 15:31       ` Yannick Duchêne (Hibou57)
2010-08-15 15:30     ` Yannick Duchêne (Hibou57)
2010-08-15 16:10       ` Dmitry A. Kazakov
2010-08-16 10:57     ` Stephen Leake
2010-08-15 15:58 ` Simon Wright
2010-08-15 16:03   ` Florian Weimer
2010-08-17  3:32     ` Randy Brukardt
2010-08-16  9:12 ` anon
replies disabled

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