From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Re: Dynamic modules: emacs-module.c and signaling errors Date: Wed, 25 Nov 2015 00:12:25 -0800 Message-ID: <56556D69.3030104@dancol.org> References: <83k2p7xk13.fsf@gnu.org> <87wpt7p369.fsf@tromey.com> <83d1uzxgvw.fsf@gnu.org> <5654D7CF.90001@cs.ucla.edu> <5654DCDC.3090200@dancol.org> <56555A96.3040001@cs.ucla.edu> <56555D4F.10508@dancol.org> <56555FE6.4080702@cs.ucla.edu> <565560AD.1070700@dancol.org> <565561F9.6060405@cs.ucla.edu> <5655627D.3020200@dancol.org> <56556812.50105@cs.ucla.edu> <565568B5.4070802@dancol.org> <56556A26.8010207@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="tf8Sfn1msbldS2KvriSPxb6nwDv0xb9LB" X-Trace: ger.gmane.org 1448439166 9421 80.91.229.3 (25 Nov 2015 08:12:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Nov 2015 08:12:46 +0000 (UTC) Cc: aurelien.aptel+emacs@gmail.com, p.stephani2@gmail.com, tzz@lifelogs.com, emacs-devel@gnu.org To: Paul Eggert , Eli Zaretskii , Tom Tromey Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 25 09:12:43 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a1VBu-0002U3-9K for ged-emacs-devel@m.gmane.org; Wed, 25 Nov 2015 09:12:38 +0100 Original-Received: from localhost ([::1]:43771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1VBw-0005KP-0A for ged-emacs-devel@m.gmane.org; Wed, 25 Nov 2015 03:12:40 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1VBq-0005K1-NT for emacs-devel@gnu.org; Wed, 25 Nov 2015 03:12:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1VBp-0007vV-Gq for emacs-devel@gnu.org; Wed, 25 Nov 2015 03:12:34 -0500 Original-Received: from dancol.org ([2600:3c01::f03c:91ff:fedf:adf3]:36667) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1VBp-0007vO-7v; Wed, 25 Nov 2015 03:12:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:Cc:References:To:Subject; bh=Bv3ceZ7dvcxiDx1uUOH05jqwONuahUiNimyLFeJ3bIA=; b=N4e2COpM9J2PqZkiHAzv2eRpauDB7j+YjU75ZnrNqsDxzLuYAl1iy71IO2EgZhhRKC0Xa4l7My3VfEXg8PDGmukOtamv8Np7q9kwYmoq82cznTpaKOAwR3zP23dwpb+rVW6+SywXm2EhlAr5jCyK8EzlGAiz/AU9NX3Y7cDW54/Rc1bTYAt+flxHy8krOof7qwQWbgOEG1i7v0fm54K0gSSTpPMmqw2+/0H6FiqzAuPFyJgoKoiTqw6AgC29KmgK2Wfmgjkh5tPnmzamxGNxVCeanDnlLbHwSh6kFTjsTKHnlZ0fKvuWW3yE5NSzM44QbJDLMk4DZD09PLdi1n+83A==; Original-Received: from [2620:10d:c090:180::4cf7] (helo=[IPv6:2620:10d:c081:1103:2ab2:bdff:fe1c:db58]) by dancol.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1a1VBo-0003rQ-0o; Wed, 25 Nov 2015 00:12:32 -0800 X-Enigmail-Draft-Status: N1110 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <56556A26.8010207@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2600:3c01::f03c:91ff:fedf:adf3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:195216 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --tf8Sfn1msbldS2KvriSPxb6nwDv0xb9LB Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/24/2015 11:58 PM, Paul Eggert wrote: > Daniel Colascione wrote: >> What's your alternative? >=20 > I don't have one right now. But surely a better API can be devised. >=20 > I agree that checking errors in return values is reasonable for things > like 'open'. But memory allocation is so basic. You could argue that file descriptors are basic. They're just handles to bits of kernel memory, right? Memory is a resource like anything else, and like all resources, can be exhausted. (Overcommit is no answer: you can't overcommit address space.) We have to do _something_ on memory exhaustion, and the only reasonable choices are communicating the failure up the call stack and aborting. Aborting is brittle, so I'd rather not do it. In the Emacs core, we can activate the low-memory code and let users save work, but if we abort because a module asks us to allocate, we'll lose data. > Plus, the method for > checking errors in the current API is awkward and confusing. It'd be a > real turnoff to have to use it after each little step in one's program.= Well, there's the Xlib method, where calls just silently fail until you bother checking for error. I think that's even more cumbersome, since it makes isolating the source of an error difficult unless your program runs in synchronous mode. Lots of extension APIs require error checks. Python's in particular comes to mind. Using these APIs doesn't feel particularly onerous. That said, I agree that the specific API for error checking is cumbersome. The function name is long, and comparing the value it returns to a specific sentinel feels awkward. IMHO, we could simplify it to if(env->error_p(env)) { return NULL; } (The name "error" here isn't strictly accurate, but I think it's close enough, and it's short. --tf8Sfn1msbldS2KvriSPxb6nwDv0xb9LB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCAAGBQJWVW1pAAoJEN4WImmbpWBlhwoP/j7tw8AOOk1JwmSlE6YNbwAv U0jW69q76pPXqj/jqAq288aayzPRewo5AI4/4GWU0rrX2ZTYe+8xgD7z+pIeHBZN G3BmJykBwDYUcXwCd9yI21pdZNgAiue72Rqx20sQD5qdOvdsNtcmuSH5xwbpAbtq Pzy9q4tW60/tZ1YcwvpEa4KEZ4GodfJXO3hyQAwx/vvr4RilJCfZg8JrR3gc6JwK 6pcTU4x57EQqGy4D8VP2/zj6FZyNyZDTdaetofrXZat8JypuNx8Hkm6aqbOS0PNA 9G0K0FNiNhx2jt2xNnCer38Gb7OPGNgBC+xVldfpKdK6M4+cv4THazsLJPJ8tuCv QGvDAO2EaE+pWN7r84VV1LVbF3TtsVThhObZArYb9xS/uAXy0LzEI32DjC6hfY+F VQlP/mNOzBd6cAdOL/rMEXZEgul+RKj3OYQ+dBEwbNEdhv2fK67IXOdXMSCI9p18 yl6HxQjbYdLxzRzM7yJ1EfBQ7GI/upqPPI0FNPxBOwUBBNt1gLAsnNEO066fNuGD w4dI9vL0OA5QtnH4DtpYnmIMUAmaYqF38ehwYczFuOuWDuAwTwSyDjFpRgBejm1L OYxc86gXFDwAx9TlQEndsNM3GeQ0MDE+cXHtzCU8fKj8rkkh7+gOhd0FW6CS/dXc /yUiqimUoopj0qzWhHed =dlQX -----END PGP SIGNATURE----- --tf8Sfn1msbldS2KvriSPxb6nwDv0xb9LB--