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: a07f3367d7,c98f618755b0ddcc X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border1.nntp.dca.giganews.com!nntp.giganews.com!feedme.ziplink.net!news.swapon.de!fu-berlin.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Thinking of using Ada for a job at home. Couple of questions first. Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <60hto51vmooku9r7j6dmviqbnglhp0pra7@4ax.com> Date: Wed, 3 Mar 2010 23:20:34 +0100 Message-ID: NNTP-Posting-Date: 03 Mar 2010 23:20:33 CET NNTP-Posting-Host: 864acccd.newsspool2.arcor-online.net X-Trace: DXC=1fd6g`WEWTA78PK[oJ2ng@A9EHlD;3YcB4Fo<]lROoRA8kF On Wed, 03 Mar 2010 20:38:01 +0000, John McCabe wrote: > As for the tagged Connection type, I'm not sure what you mean. Would > you mind elaborating on that please? I meant something like this: type Abstract_Connection is tagged ...; procedure On_XYZ (Link : in out Connection) is abstract; ... task type Driver (Link : not null access Abstract_Connection'Class); task body Driver is begin loop -- read a message (could be polymorphic or not) ... -- process the message (usually polymorphic) case ... is when XYZ => -- XYZ is here Link.On_XYZ; -- Do what has to be done when ... => ... end case; end loop; exception when Shut_Down_Exception => null; when Error : others => Put ("I am dead! " & Exception_Information (Error)); end Driver; type My_Fancy_MIDI_Connection is new Abstract_Connection with private; overriding procedure On_XYZ (Link : in out My_Fancy_MIDI_Connection); ... I usually have a driver task which deals with a class-wide Connection object that implements the lower-level communication protocol (the part that reads messages) and the higher-level semantic call-backs (the part that reacts to the messages read). If the communication library is built on callbacks (i.e. already has a hidden Driver task), then I pass the connection object as user parameter to the callback, and the loop body above is what to be done in the callback routine. The advantage of having Connection tagged is that I can implement layered protocols and semantic actions incrementally. In complex cases I add further mix-ins as access discrimnants to Connection, usually when I need to make lower layers pluggable. But that would be over the top in your case. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de