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.3 required=5.0 tests=BAYES_00,HEADER_SPAM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b30bd69fa8f63cb2 X-Google-Attributes: gid103376,public X-Google-Thread: fc772,b30bd69fa8f63cb2 X-Google-Attributes: gidfc772,public X-Google-ArrivalTime: 2003-06-22 16:59:49 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!nntp-relay.ihug.net!ihug.co.nz!news-out.newsfeeds.com!propagator2-maxim!news-in-maxim.spamkiller.net!usc.edu!rpi!not-for-mail From: =?Windows-1252?Q?Terje_Sletteb=F8?= Newsgroups: comp.lang.ada,comp.lang.c++.moderated Subject: Re: C bug of the day Date: 22 Jun 2003 20:02:04 -0400 Organization: unknown Sender: cppmods@netlab.cs.rpi.edu Message-ID: References: <7gBHa.12174$KF1.273806@amstwist00> NNTP-Posting-Host: netlab.cs.rpi.edu X-Original-Date: Sun, 22 Jun 2003 16:36:00 +0200 X-Submission-Address: c++-submit@netlab.cs.rpi.edu X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated iQBVAwUAPvZDeEHMCo9UcraBAQEMOwH9H69UmZpmu8/0uiXIKDKVguF5kl9XT7pb 1O9UZbLReGIWa+ngERxxZaI5olTOTjSH98pzn4Tf7A/pqNOUT65xoA== =NCoI Xref: archiver1.google.com comp.lang.ada:39578 comp.lang.c++.moderated:68954 Date: 2003-06-22T20:02:04-04:00 List-Id: "Dave Harris" wrote in message news:memo.20030621140227.60519A@brangdon.madasafish.com... > tslettebo@chello.no.nospam (=?Windows-1252?Q?Terje_Sletteb=F8?=) wrote > > > Garbage collection might make it harder to manage resources, not > > easier. > > How? I meant that people not used to GC may meet problems they aren't prepared for, such as these memory-leak like situations. Naturally, this depends on what you're used to. Someone used to GC may have just as much difficulty with a non-GC language. So I guess this is not an argument against GC, per se, but more to acknowledge that the problems you meet are typically different. > (GC is a big win when objects can be shared by pointers which are > encapsulated. Then the question, "Has everyone finished with this > object?" gets replaced by "Have I finished with this pointer?", > which is a more local, encapsulated issue - fundamentally easier.) You get something similar with reference-counted smart pointers. > > For languages without stack-allocated objects, like Java, you > > can't use RAII in its usual form, either (use of > > constructor/destructor). Instead, you have to resort to > > try-catch-finally, which can lead to spaghetti code, if you > > have several objects to clean up this way. > > This would be a criticism of Java, not GC. Most GC languages have > idioms to encapsulate stack-based cleanup. (These are often based > on closures.) RAII is only "usual" in C++. In what way does this differ from RAII in C++. Could you give an example from one of those languages? Regards, Terje [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]