Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: No, C is not a simple language Date: Tue, 11 May 2021 05:31:48 -0700 Organization: A noiseless patient Spider Lines: 43 Message-ID: <86tun9fo3v.fsf@linuxsc.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="ce98507e466523ba1e4f65ba30f9b784"; logging-data="9112"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XwtwmlH9E2aJImpT/YomVQ481JP42e5Q=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:vveXyR8+YPj2/y8cL9MIVLH6RSY= sha1:BVG5bQh9rpdy5WtCg1dR+bDbb+s= Xref: csiph.com comp.lang.c:160732 Richard Damon writes: > On 4/20/21 1:44 PM, jacobnavia wrote: > >> Le 20/04/2021 at 18:41, Juha Nieminen a ecrit: >> >>> The problem with C is that anything that requires manual construction and >>> destruction will "contaminate" (can't think of a better word) anything >>> that >>> uses that first thing, with the same requirements. All the way down. >>> >>> If you have this kind of "string" object that requires manual >>> construction >>> and destruction, and you put it as a member of a struct, suddenly that >>> struct "inherits" the same requirement. Use that struct in yet another >>> struct and that, too, will "inherit" the same requirement. >> >> No. >> >> Just have a constructotr and never free anything. Then link with Boehm's >> GARBAGE COLLECTOR and be done with it! >> >> I have already said this in this thread but people will go on arguing >> about how difficult is to keep the accounting of memory pieces right. >> >> And they are right but refuse to see the right tool for theirpurpose: >> just use a garbage collector and BE DONE WITH IT. >> >> I use an automatic car, no passing of gears. Recently I spoke with a >> taxi driver... "Don't you get bored passing gears all day?" >> >> And he acknowledged: yes, My arm hurts at the end of the day. Maybe you >> are right, should get an automatic... >> >> Use an automatic garbage collector and BE DONE WITH IT. And please, do >> not start with performance problems, in most string applications the gc >> is completely transparent. > > But that only works for a fungible resource like memory. If you really > need to release the resource right away (like a lock on something) you > really want RAII. Or some other resource management mechanism, not RAII necessarily.