From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: OO problem: Performing actions on messages (very long, sorry)
Date: Wed, 5 Jan 2005 21:44:31 +0100
Date: 2005-01-05T21:44:31+01:00 [thread overview]
Message-ID: <1rall0nftkcsj$.1e5jj6uwwwezc.dlg@40tude.net> (raw)
In-Reply-To: 1104940745.420814.235130@f14g2000cwb.googlegroups.com
On 5 Jan 2005 07:59:05 -0800, per wrote:
>>OK, I see. But then the question to answer what purpose serves message
>>apart from being just a container for unrelated data? The difficulties of
>>the design come from that missing pupose. If there is nothing in common
>>then nothing can be programmed for that nothing. (:-))
>
> Well, each message *is* a simple container, more or less. The contents
> are related in the sense they are to be sent to/from a certain device
> that expects a defined set of information. The program we discuss
> doesn't really care at all of the contents of each message, but shall
> provide means to the user to override any message content (among other
> things).
How do you plan to maintain data consistency of a message if the user may
arbitrarily override its fields? I would try to do it more OO. To think
about what can be done with a message. And consider action as an
implementation detail of a concrete type of messages. Then actions could
vanish. (Just a guess, I still can't tolerate both messages and actions in
one bottle. (:-))
>>Hmm, what about this mix-in:
>>
>>package Interfaces is
>> type Message is abstract tagged ...
>> type Action is abstract tagged limited ...;
>> procedure Execute (This : in out Action) is abstract;
>>end Interfaces;
>>
>>package M1_Thinds is
>> type M1 is new Message with record -- Message M1
>> A : Integer;
>> B : Float;
>> end record;
>>
>> type M1_Action (Data : access M1) is -- Abstract actions on M1
>> abstract new Action with null record;
>>
>> type Override_A is new M1_Action with record
>> A : Integer;
>> end record;
>> procedure Execute (This : in out Override_A);
>>
>> type Override_B is new M1_Action with record
>> B : Float;
>> end record;
>> procedure Execute (This : in out Override_B);
>> ...
>>
>>package body M1_Things
>> procedure Execute (This : in out Override_A) is
>> begin
>> This.Data.A := This.A;
>> end Execute;
>>
>> procedure Execute (This : in out Override_B) is
>> begin
>> This.Data.B := This.B;
>> end Execute;
>>
>>Here all actions on some type of messages have a "pointer" to the
>>corresponding message object. The scope of an action should be nested in
>>the scope of the message.
>>
>>Here in fact action is a pointer to message extended with some additional
>>data. When scopes get different, then action could be a handle to message.
>>Messages will be collected using reference counting.
>
> I kind of see what this aims at (although "mix-in" is new to me).
>
> As far as I see we're back to defining one action type for each message
> and each field in the message, although this time without the generics,
> right?
Yes, generics do not help here much because the field name cannot be a
formal parameter.
> Can an action, eg Override_A, exist without an M1 instance to "point"
> at?
It cannot, this is the whole idea of access discriminants. They are never
null and cannot be changed. Otherwise one should use access types
(pointers).
> Action has a different life-cycle than Message.
That's no problem as long as its life in Message's one. For exampe:
declare
M : aliased M1;
begin
...
declare
A : Override_A (M'Access);
begin
... -- The scope of the action A is nested
end;
...
end;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2005-01-05 20:44 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-22 13:49 OO problem: Performing actions on messages (very long, sorry) per
2004-12-22 15:17 ` Dmitry A. Kazakov
2004-12-22 16:28 ` Martin Krischik
2004-12-22 17:42 ` per
2004-12-22 18:16 ` Martin Krischik
2004-12-22 19:54 ` Dmitry A. Kazakov
2005-01-03 12:37 ` per
2005-01-03 14:14 ` Dmitry A. Kazakov
2005-01-04 12:05 ` per
2005-01-04 13:30 ` Dmitry A. Kazakov
2005-01-04 15:21 ` per
2005-01-04 17:47 ` Dmitry A. Kazakov
2005-01-05 12:01 ` per
2005-01-05 13:23 ` Dmitry A. Kazakov
2005-01-05 15:59 ` per
2005-01-05 20:44 ` Dmitry A. Kazakov [this message]
2005-01-10 8:42 ` per
2005-01-10 14:22 ` Dmitry A. Kazakov
2005-01-10 16:24 ` per
2005-01-10 19:09 ` Dmitry A. Kazakov
2005-01-11 9:06 ` per
2004-12-22 17:46 ` per
2004-12-22 18:02 ` Martin Krischik
2005-01-03 10:05 ` per
2004-12-22 18:35 ` u_int32_t
2004-12-22 18:38 ` u_int32_t
2004-12-24 18:52 ` Nick Roberts
2005-01-03 16:59 ` per
2005-01-10 12:10 ` per
2005-01-10 13:49 ` Marius Amado Alves
2005-01-10 21:54 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox