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!news4.google.com!news.glorb.com!newsfeed.kamp.net!newsfeed.freenet.de!151.189.20.20.MISMATCH!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> <97kpu5gkgo1r$.kc4nx7cxjziw$.dlg@40tude.net> Date: Fri, 11 Mar 2005 11:14:09 +0100 Message-ID: NNTP-Posting-Date: 11 Mar 2005 11:10:49 MET NNTP-Posting-Host: 970c1997.newsread2.arcor-online.net X-Trace: DXC=Wo:iFJd On Fri, 11 Mar 2005 10:42:51 +0100, Peter Koch Larsen wrote: > "Dmitry A. Kazakov" skrev i en meddelelse > news:97kpu5gkgo1r$.kc4nx7cxjziw$.dlg@40tude.net... >>>> 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)); > > The solution is simple here - just allocate your memory on the heap. Heap is far slower than stack. Also stack is much safer, because objects allocated on the stack have visible scopes, as compared to adventures with pointers. Do you want to add one more indirection layer - smart pointers, or do it even worse by using GC? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de