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,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!news3.google.com!news.glorb.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Wes Groleau Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: Wed, 09 Mar 2005 22:26:16 -0500 Organization: Ain't no organization here! Message-ID: <399t26F5o9214U1@individual.net> 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> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <1110377260.350158.58730@z14g2000cwz.googlegroups.com> Reply-To: groleau+news@freeshell.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net U9m7bqFDbsn1JpeBMj1AsAC+H7JCQc070dSO8fwNB59Ybf0WQz User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) X-Accept-Language: en-us, en In-Reply-To: <1110377260.350158.58730@z14g2000cwz.googlegroups.com> Xref: g2news1.google.com comp.lang.ada:8997 comp.lang.c++:44893 comp.realtime:1173 comp.software-eng:4735 Date: 2005-03-09T22:26:16-05:00 List-Id: Hans Malherbe wrote: > * case statements (Ada's equivalent of a switch in C++) are required > to handle all possible cases. Thus it is impossible to forget one. > And, of course, there is no "break;" crap in Ada. > > Prevents fall through. And it prevents forgetting to put in the break--an error so common that the feature was explicitly prohibited in the Ada specs. > This is more in the C++ tradition. The programmer has choice. > In C++ you can extend the type system to achieve this and more > (someone mentioned dimensional analysis), just not with typedef. In C++ and Java, you can do a heck of a lot to program type safety and abstraction. Problem is that it _is_ a heck of a lot -- for example, to emulate what Ada does with things like type Possible_Speed is range 0.0 .. 140.0; constant Speed_Limit is 55.0; subtype Legal_Speed is Possible_Speed range 0.0 .. Speed_Limit; type Direction is mod 360; V : Legal_Speed; C, D : Direction; Before you say it doesn't take much, remember your solution should allow V := Speed_Limit - 15.0; raise an exception on ..... V := 55.1; and it should refuse to compile the typo V := D; Another problem is that because of the work involved in enforcing abstractions with classes, most Java programmers (probably C++, too) would rather just say double V; double C, D; -- Wes Groleau A pessimist says the glass is half empty. An optimist says the glass is half full. An engineer says somebody made the glass twice as big as it needed to be.