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!news1.google.com!proxad.net!proxad.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: [OT] Re: Teaching new tricks to an old dog (C++ -->Ada) Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng User-Agent: 40tude_Dialog/2.0.14.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: <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> <1lr611thktbau$.1dj95z21h7l5v.dlg@40tude.net> Date: Fri, 11 Mar 2005 10:30:01 +0100 Message-ID: <97kpu5gkgo1r$.kc4nx7cxjziw$.dlg@40tude.net> NNTP-Posting-Date: 11 Mar 2005 10:26:41 MET NNTP-Posting-Host: 010dbd40.newsread2.arcor-online.net X-Trace: DXC=jggG_l\WJ8MbkXRh2MA`7OQ5U85hF6f;DjW\KbG]kaMH]kI_X=5KeaF?InVSNRB8ZCWRXZ37ga[7Jn919Q4_`VjIB8=X\UUgbkD X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:9116 comp.lang.c++:45096 comp.realtime:1259 comp.software-eng:4827 Date: 2005-03-11T10:26:41+01:00 List-Id: On 11 Mar 2005 00:05:06 -0800, Alberto wrote: > "Dmitry A. Kazakov" wrote in message news:<1lr611thktbau$.1dj95z21h7l5v.dlg@40tude.net>... >> 3. The size of all exception objects has an upper bound. > > What is the advantage here? :) You can catch the exception Storage_Error! (:-)) >> But even then bounds checking is not needed for every access. Example: >> >> procedure Dynamic (A : Some_Array) is >> subtype Index is Array_Index range A'Range; >> J : Index := A'First; >> >> for I in A'Range loop >> A (I) := .. -- No checks >> ... >> J := I; >> end loop; >> A (J) := ... -- Still no checks >> >> C++ completely lacks the notion of constrained subtypes which makes the >> above possible. > > If Some_Array is any array supplied at run-time, how can the compiler > know what values are stored in A'Range? (I mean, what the bounds of > the array are) The bounds are in the array dope. > It *has* to check these bounds at run-time. This > behaviour is also easily done with C++, creating a 'bounds' class, > similar to A'Range. The only difference is that it is a mechanism > provided by the user and not the compiler. No, the difference is that the compiler *statically* knows that both I and J will be in the bounds at run-time. There is no way (except for dirty tricks with casting) how they might become out of the bounds. Therefore the compiler can safely omit any checks. >>> 4. Also, some people wrote that C++ is bad because it is difficult >>> (but not imposible, see Comeau C++) to follow 100% the Standard. The >>> same can be said to adA, because at least if we own a compiler of the >>> '83 Standard, we can't have the derivation a virtual function >>> mechanisms, only interfaces (pure virtual classes)[2]. To me, it >>> sounds reasonable to work with the last version of a compiler when >>> possible. >> >> As long as you have only one compiler vendor... > > Sorry, I don't understand you very well here. If your code depends on the compiler version, and you have to compile it under gcc, Borland, MSVC, then you are in trouble man! >> 2. C++ is unable to allocate objects of indefinite size on the stack. > > Well, we have alloca() for this ;) Try to return such object from a function. Ada can declare Object : T'Class := Read_It_From_File; Here neither the specific type, nor the size of the object are known at compile time. Another example: declare Line : String := Read_Source_Line (File); Or even: Put_Line (Read_Source_Line (File)); -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de