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,147f221051e5a63d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed-0.progon.net!progon.net!news-zh.switch.ch!switch.ch!news.ip-plus.net!newsfeed.ip-plus.net!news.post.ch!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: memory management in Ada: tedious without GC? Date: Mon, 19 May 2008 12:27:31 +0200 Organization: Swisscom IP+ (post doesn't reflect views of Swisscom) Message-ID: <48315614$1@news.post.ch> References: <4ddef8bf-b5b1-4d7e-b75b-386cd6c8402c@l17g2000pri.googlegroups.com> <482E8A9D.5040401@obry.net> <8640a12f-da99-435f-8eb6-372e175cd5b9@z72g2000hsb.googlegroups.com> <482F19CE.7060306@obry.net> <87d4nkzhtn.fsf@willow.rfc1149.net> <2545491.n7xu0MFufK@linux1.krischik.com> <5209773.UsCT0IWhbo@linux1.krischik.com> <82e2924a-4888-4b45-a4de-f33f905334c2@n1g2000prb.googlegroups.com> NNTP-Posting-Host: 194.41.146.1 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: atlas.ip-plus.net 1211192855 21356 194.41.146.1 (19 May 2008 10:27:35 GMT) X-Complaints-To: abuse@ip-plus.net NNTP-Posting-Date: Mon, 19 May 2008 10:27:35 +0000 (UTC) User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) In-Reply-To: <82e2924a-4888-4b45-a4de-f33f905334c2@n1g2000prb.googlegroups.com> X-Original-NNTP-Posting-Host: w03duo.pnet.ch X-Original-Trace: 19 May 2008 12:27:32 +0100, w03duo.pnet.ch Xref: g2news1.google.com comp.lang.ada:232 Date: 2008-05-19T12:27:31+02:00 List-Id: jhc0033@gmail.com schrieb: > On May 18, 8:03 am, Martin Krischik > wrote: >> jhc0...@gmail.com wrote: >>> Oh, panlinguistic guru, I'd like to see you try to implement "STL" in >>> C! I wonder if you'll go for macros or void* type casts with type >>> sizes as explicit parameters. How will you implement automatic memory >>> management and deep copy semantics for arbitrary user-constructed type >>> parameters? >> I start with: >> >> typeset struct Vector Vector; >> >> Vector* Create_Vector(int Element_Count, size_t Element_Size); > > Already, this can not do what "vector v(n)" does. > >> and take it from there. Won't have the same syntax - but the semantic is >> doable. > > That's because you don't understand what RAII is, or how it interacts > with "return" and exceptions. I see, you insist that: typedef Element* Element_Create(); typedef Element_Destroy(Element* An_Element); is passed as parameters to Create_Vector so Vector can initialize and terminate Elements. Ok, the syntax gets ugly, and there is some nasty casting needed now but still doable. Note that while I think it was a mistake to do so GNOME is a OO Framework based on C. Regards Martin -- mailto://krischik@users.sourceforge.net Ada programming at: http://ada.krischik.com