From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: Dynamic modules: MODULE_HANDLE_SIGNALS etc. Date: Sat, 19 Dec 2015 21:03:32 +0000 Message-ID: References: <83mvu1x6t3.fsf@gnu.org> <565779CD.80405@cs.ucla.edu> <83io4nuc68.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=089e0102def443ee02052746971d X-Trace: ger.gmane.org 1450559035 6285 80.91.229.3 (19 Dec 2015 21:03:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Dec 2015 21:03:55 +0000 (UTC) Cc: aurelien.aptel+emacs@gmail.com, tzz@lifelogs.com, dancol@dancol.org, emacs-devel@gnu.org To: Eli Zaretskii , Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 19 22:03:54 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 1aAOfQ-0005R0-T8 for ged-emacs-devel@m.gmane.org; Sat, 19 Dec 2015 22:03:53 +0100 Original-Received: from localhost ([::1]:38628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAOfQ-00088x-At for ged-emacs-devel@m.gmane.org; Sat, 19 Dec 2015 16:03:52 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAOfL-00086P-5A for emacs-devel@gnu.org; Sat, 19 Dec 2015 16:03:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAOfJ-00017z-Qz for emacs-devel@gnu.org; Sat, 19 Dec 2015 16:03:47 -0500 Original-Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:34790) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAOfH-00017h-IB; Sat, 19 Dec 2015 16:03:43 -0500 Original-Received: by mail-wm0-x22e.google.com with SMTP id l126so25635125wml.1; Sat, 19 Dec 2015 13:03:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=fezNd9cDrgvtBulALLWbUD4993/OMRKC679X4ZVZH4I=; b=EcQeMtPgO0j4vki5f5OuIz5BBc9RhhRc82m/Ns5YRXkyXBN1imZlyXOQrjhSrgehAM BB+gu2NUC5KWWGmYMAi1pcAkTonjrl73m2Ttmif4zKRKIyZTxQfRdvablczFNRVFSpm9 bYMuUBNUpsidl9POXncyLNjYAFzlTQDdyiuFOjfzCGelOvYc5Z5rE9/Rq5wkeLaWLrxa vUddINvUM76ISHEAj7LPnEs1WBRQSwdM3cD4IBwWR6zoA+ibs4v9FQBtG9BubXSRehke zi9x2OgHPlgfWO5w1SyUQwp5gbp4OLFCSfhSeIvaUGRMfcjEomiJl5lPnwjadiraDe+2 a+HQ== X-Received: by 10.194.87.39 with SMTP id u7mr11432458wjz.11.1450559022453; Sat, 19 Dec 2015 13:03:42 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22e 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:196527 Archived-At: --089e0102def443ee02052746971d Content-Type: multipart/alternative; boundary=089e0102def443edfc052746971b --089e0102def443edfc052746971b Content-Type: text/plain; charset=UTF-8 Philipp Stephani schrieb am Sa., 28. Nov. 2015 um 11:58 Uhr: > Philipp Stephani schrieb am Fr., 27. Nov. 2015 um > 20:19 Uhr: > >> Eli Zaretskii schrieb am Fr., 27. Nov. 2015 um 08:36 Uhr: >> >>> > Cc: emacs-devel@gnu.org >>> > From: Paul Eggert >>> > Date: Thu, 26 Nov 2015 13:29:49 -0800 >>> > >>> > Eli Zaretskii wrote: >>> > > it would be a maintenance burden to have to >>> > > analyze upon each such change whether emacs-module.c needs some >>> > > augmentation. >>> > >>> > While that's true in general, I think some exceptions are OK. E.g., >>> it's OK if >>> > emacs-module.c assumes that ASIZE is a simple access function or macro >>> that >>> > doesn't throw signals. If we actually changed ASIZE to throw signals, >>> there's a >>> > boatload of other code we'd need to change as well, and changing >>> emacs-module.c >>> > wouldn't add much more to the maintenance burden. >>> >>> So what are the rules here, exactly? I'd like to write them down in >>> the commentary to emacs-module.c, so that any future changes there >>> will have lower probability of breaking things. >>> >>> E.g., can make_number signal an error? What about make_float or >>> make_string? And what about accessors like XFLOAT_DATA or AREF? >>> >>> >> Are there any established rules? If not we should probably be >> conservative and assume that everything signals. If we figure out that >> this introduces an unacceptably high overhead in some situations we can >> reconsider later. >> I would propose three exceptions: free_global_ref, is_not_nil, eq. >> free_global_ref cannot fail in Daniel's design, and implementing it that >> way would be consistent with other resource deallocation functions such as >> free(3). is_not_nil and eq seem so fundamental that I cannot imagine a >> situation where they could ever fail. Documenting that these three cannot >> fail would free module authors from the need to check for errors after >> calling these functions. >> > > For now I've attached a patch to replace the initial setup of most > environment functions with a single macro. > Here's another patch that replaces some of the custom error handling with signals. The signals will be immediately caught by the prologue, but some complexity and duplication is removed. --089e0102def443edfc052746971b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Philip= p Stephani <p.stephani2@gmail.c= om> schrieb am Sa., 28. Nov. 2015 um 11:58=C2=A0Uhr:
Philipp Stephani <p.stephani2@gmail.com> schrieb am Fr., 27. Nov. 2015= um 20:19=C2=A0Uhr:
Eli Zaretskii <eliz@gnu.org> schrieb am Fr.,= 27. Nov. 2015 um 08:36=C2=A0Uhr:
&= gt; Cc: emacs-deve= l@gnu.org
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Thu, 26 Nov 2015 13:29:49 -0800
>
> Eli Zaretskii wrote:
> > it would be a maintenance burden to have to
> >=C2=A0 =C2=A0 =C2=A0 analyze upon each such change whether emacs-m= odule.c needs some
> >=C2=A0 =C2=A0 =C2=A0 augmentation.
>
> While that's true in general, I think some exceptions are OK.=C2= =A0 E.g., it's OK if
> emacs-module.c assumes that ASIZE is a simple access function or macro= that
> doesn't throw signals.=C2=A0 If we actually changed ASIZE to throw= signals, there's a
> boatload of other code we'd need to change as well, and changing e= macs-module.c
> wouldn't add much more to the maintenance burden.

So what are the rules here, exactly?=C2=A0 I'd like to write them down = in
the commentary to emacs-module.c, so that any future changes there
will have lower probability of breaking things.

E.g., can make_number signal an error?=C2=A0 What about make_float or
make_string?=C2=A0 And what about accessors like XFLOAT_DATA or AREF?


Are there any established rules? If not we should probabl= y be conservative and =C2=A0assume that everything signals. If we figure ou= t that this introduces an unacceptably high overhead in some situations we = can reconsider later.
I would propose three exceptions: free_glob= al_ref, is_not_nil, eq. free_global_ref cannot fail in Daniel's design,= and implementing it that way would be consistent with other resource deall= ocation functions such as free(3). is_not_nil and eq seem so fundamental th= at I cannot imagine a situation where they could ever fail. Documenting tha= t these three cannot fail would free module authors from the need to check = for errors after calling these functions.

Fo= r now I've attached a patch to replace the initial setup of most enviro= nment functions with a single macro.=C2=A0

Here's another patch that replaces some of the cu= stom error handling with signals. The signals will be immediately caught by= the prologue, but some complexity and duplication is removed.=C2=A0
<= /div>
--089e0102def443edfc052746971b-- --089e0102def443ee02052746971d Content-Type: application/octet-stream; name="0001-Use-standard-checks-whenever-possible.patch" Content-Disposition: attachment; filename="0001-Use-standard-checks-whenever-possible.patch" Content-Transfer-Encoding: base64 Content-ID: <151bc0d69e974f30c1c1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