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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a8d137db7a5f6c81 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!irazu.switch.ch!switch.ch!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: OO problem: Performing actions on messages (very long, sorry) Date: Wed, 22 Dec 2004 19:16:30 +0100 Organization: None Message-ID: <1285664.R9jkH16bOA@linux1.krischik.com> References: <1103723394.299024.314670@c13g2000cwb.googlegroups.com> <13465377.hrn0RlrJV7@linux1.krischik.com> <1103737351.196460.85450@f14g2000cwb.googlegroups.com> Reply-To: martin@krischik.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1103739800 03 19159 XSXZrd-vJsZlJPp 041222 18:23:20 X-Complaints-To: usenet-abuse@t-online.de X-ID: rwq4+2ZTZe1nwH4rE9vAnjKqZhpePqTz5x0XJHzDb2z0uCo2XL754N User-Agent: KNode/0.8.0 Xref: g2news1.google.com comp.lang.ada:7175 Date: 2004-12-22T19:16:30+01:00 List-Id: per wrote: > Hi Dimitri, thanx for your answers. > > Sorry for the yucky code/text. All indentation and line breaks was > screwed up:( I'm using google groups (for the first time). Not very > user friendly. Had to compose this answer in a separate file and > manually paste in the citations so this answer is also a bit yucky... > >>> Each action child shall be able to "do something" with a message in > the >>> virtual (is that the Ada term?) procedure Execute. >> >>No. It is called "primitive operation". > > OK. But is there no distinction between operations that may dispatch > and those those who cannot? Execute, for example, may be a primitive > operation of each child regardless of if the parent has declared it or > not. So "primitive operation" doesn't tell that dispatching will be > possible or not, right? All primitve operations dispach. >>> The action Action.Override serves as an example in this post. This >>> action shall override a field in a message. >> >>One cannot override a field. Presently Ada's inheritance model is a > type >>extension one. I.e. you can add a field, but not replace it with > another. > > No! I was unclear. I'm not trying to override anything in that sense. > > The messages are basically records filled with values. It's the > _values_ in the existing message structures the Action.Override is > supposed to override: > type Instance is new Message.Instance with > record > A : Float; > B : Integer; > ... > end record; Maybe you want to read about a "variant record": http://en.wikibooks.org/wiki/Programming:Ada:Types:record#Variant_Record It just might get you a new idea. > Somewhere some mechanism assigns the initial values: > M1 : Message.M1.Instance; > Put_A(M1, 1.0); > Put_B(M1, 1); You could try a qualified expression: http://en.wikibooks.org/wiki/Programming:Ada:Subtypes#Evaluate_As >>procedure Put (M : Instance; A : ArgumentType) is >>begin >> M.Extension := A; >>end Put; > > You're saying I should replace every single field in every message > record with an extension as above? Well, a variant record initialized by a qualified expression might be the better option. With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com