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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!newspeer.monmouth.com!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.multikabel.nl!tudelft.nl!130.161.131.116.MISMATCH!tudelft.nl!transit0.news.tiscali.nl!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscali.nl!not-for-mail Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <87is4598pm.fsf@insalien.org> <1110054476.533590@athnrd02> <1110059861.560004@athnrd02> <87wtsl7jts.fsf@insalien.org> <1110264816.858853.54020@l41g2000cwc.googlegroups.com> From: Ludovic Brenta Date: Tue, 08 Mar 2005 20:25:06 +0100 Message-ID: <87acpegctp.fsf@insalien.org> User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:sBJSyK53HouhmYTFUJb9KOIb9tE= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tiscali bv NNTP-Posting-Date: 08 Mar 2005 20:24:47 CET NNTP-Posting-Host: 83.134.245.213 X-Trace: 1110309887 dreader2.news.tiscali.nl 44082 83.134.245.213:32849 X-Complaints-To: abuse@tiscali.nl Xref: g2news1.google.com comp.lang.ada:8876 comp.lang.c++:44646 comp.realtime:1075 comp.software-eng:4629 Date: 2005-03-08T20:24:47+01:00 List-Id: "Jerry Coffin" writes: > Ludovic Brenta wrote: >> I could make the code less verbose by using use clauses, similar to >> "using namespace std" which you seem fond of. In avionics, our >> coding standards forbid that because we want everything to be >> explicit. > > A poor idea. Just for example, consider writing a generic sorting > function. It needs to swap items that it's sorting. In well-written > C++, this will often be done with a using clause. Specifically, if > the type of items has provided its own specialized version of swap, > then my sorting functino should use that, but otherwise it should > use std::swap to swap them. > > I try to specify whatever_type::swap(x,y), then compilation will > fail if the type has not provided a swap function. Conversely, if I > specify std::swap(x,y), then the specialized swap function won't be > used for those types that provide one. Ada requires explicit instanciation of all templates, so there is no "default". We do not have problems using fully-qualified names. Ada 95's object-oriented features do not suffer from this either. package P is type Base is tagged null record; procedure Method (B : in Base); end P; with P; package Q is type Derived is new P.Base with private; procedure Method (B : in Derived); -- overloads P.Method private -- omitted end Q; with P; procedure Dynamic_Dispatch (B : in Base'Class) is begin P.Method (B); -- [1] end Dynamic_Dispatch; The procedure Dynamic_Dispatch does not see package Q, yet it can call Q.Derived if it receives an instance of Q.Derived as its parameter. This, *even* without a use clause. -- Ludovic Brenta.