From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: protobuff for Ada
Date: Wed, 2 Jan 2019 11:02:10 +0100
Date: 2019-01-02T11:02:10+01:00 [thread overview]
Message-ID: <q0i272$1e47$1@gioia.aioe.org> (raw)
In-Reply-To: q0hnca$h1d$1@dont-email.me
On 2019-01-02 07:57, G. B. wrote:
> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
>
>> *If* you are OK without semantics then there is no need to introduce
>> this mess. Use Ada stream attributes and simply read and write what you
>> want and how you want. It is clean, easy, fast and 100% Ada.
>
> What kind of stream do you write for your partners in business?
Stream of octets.
> Three of
> them have different needs than you WRT data and none of them is using Ada.
They still can read and write the stream. You are confusing description
of a protocol with the implementation of.
The OP suggested having descriptions in protobuff and partial
implementation generated from that. It is a bad idea.
-------------------------------
BTW, it is very easy to write things like protobuff straight in Ada with
Simple Components
http://www.dmitry-kazakov.de/ada/components.htm#17.2.1
This feature is rarely used because, as I said, the concept is too
limited and constraining if not wrong altogether.
Here is a small example. Consider an example in protobuff:
message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
}
This direct Ada code:
type Person is new State_Machine with
Name : String_Data_Item (Max_String_Length);
ID : Unsigned_32_Data_Item;
Email : String_Data_Item (Max_String_Length);
end record;
Thanks to Ada's "introspection" that is all. It will be read or written
by the connections server automatically. On the packet receipt callback,
you get values like Person_Session.ID.Value. Before sending a new packet
you assign Person_Session.ID.Value. Note, this is Ada 95, no fancy stuff.
I didn't show here alternation for using optional fields because the
transport level representation would be different anyway. Which is the
point actually. Such key details are all left unspecified in the
protobuff "description" above along with endianness and other encoding
issues. Yet exactly these details are essential in practice where the
protocol is already defined. Present or not bits might kept combined in
the message header, special values of integers are reserved to indicate
exceptional states and so on and so forth. And, again, no semantics
whatsoever, just buckets of bits.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2019-01-02 10:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-28 18:57 protobuff for Ada Per Sandberg
2018-12-29 5:53 ` Shark8
2018-12-29 11:05 ` Dmitry A. Kazakov
2018-12-31 16:55 ` Olivier Henley
2018-12-31 17:59 ` Dmitry A. Kazakov
2019-01-01 14:56 ` Olivier Henley
2019-01-02 6:57 ` G. B.
2019-01-02 10:02 ` Dmitry A. Kazakov [this message]
2019-01-01 8:05 ` Per Sandberg
2019-01-01 15:04 ` Olivier Henley
2018-12-29 13:01 ` joakimds
2018-12-29 14:52 ` Per Sandberg
2018-12-30 0:27 ` joakimds
2018-12-30 0:28 ` joakimds
2018-12-30 6:21 ` Per Sandberg
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox