From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28221 invoked by alias); 18 Aug 2014 07:31:29 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 28212 invoked by uid 89); 18 Aug 2014 07:31:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de From: Andreas Schwab To: Rich Felker Cc: Florian Weimer , libc-alpha@sourceware.org Subject: Re: Implement C11 annex K? References: <20140814022501.GT12888@brightrain.aerifal.cx> <87r40jbq2p.fsf@windlord.stanford.edu> <20140814054610.GV12888@brightrain.aerifal.cx> <87ha1fbnrp.fsf@windlord.stanford.edu> <53EC87A4.1080805@redhat.com> <53EC8A1F.8080203@redhat.com> <20140814162628.GC12888@brightrain.aerifal.cx> <87oavn57xc.fsf@igel.home> <20140814170422.GE12888@brightrain.aerifal.cx> X-Yow: It's the RINSE CYCLE!! They've ALL IGNORED the RINSE CYCLE!! Date: Mon, 18 Aug 2014 07:31:00 -0000 In-Reply-To: <20140814170422.GE12888@brightrain.aerifal.cx> (Rich Felker's message of "Thu, 14 Aug 2014 13:04:22 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2014-08/txt/msg00276.txt.bz2 Rich Felker writes: > I disagree strongly here. If you want that, you should be using a > language where it's idiomatic. Doing it in C just gets you the worst > of both worlds: (1) C's lack of syntax to express it concisely and > lack of exceptions to handle allocation failures, which are a horrible > pain to handle when they can happen at each operation rather than at > isolated resource-allocation points, There is no need for exceptions. Only need to add a flag to the string type that is set for an allocation failure (or if the buffer is full for static allocation) that can be tested at the end of a sequence of calls. Much like stdio's ferror, but without the stdio overhead. The key point is that the allocation size should be maintained as part of the string type. > and (2) the HLL style loss of fail-safety (all operations can fail > because they do allocation under the hood), massive overhead in memory > usage and memory fragmentation, load on malloc/free, etc. It is easy to also support static allocation, but with the failure flag as above the truncation can be detected reliably after the fact. Andreas. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."