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 22:57:14 +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=001a1148e710e2f9230527482d93 X-Trace: ger.gmane.org 1450565864 4830 80.91.229.3 (19 Dec 2015 22:57:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Dec 2015 22:57:44 +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 23:57:33 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 1aAQRQ-0004ZR-Vf for ged-emacs-devel@m.gmane.org; Sat, 19 Dec 2015 23:57:33 +0100 Original-Received: from localhost ([::1]:39011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAQRQ-0004Gz-Bb for ged-emacs-devel@m.gmane.org; Sat, 19 Dec 2015 17:57:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAQRM-0004Gl-Ge for emacs-devel@gnu.org; Sat, 19 Dec 2015 17:57:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAQRL-00015M-6Z for emacs-devel@gnu.org; Sat, 19 Dec 2015 17:57:28 -0500 Original-Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:34577) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAQRJ-00014s-7M; Sat, 19 Dec 2015 17:57:25 -0500 Original-Received: by mail-wm0-x22b.google.com with SMTP id l126so27230440wml.1; Sat, 19 Dec 2015 14:57:25 -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=aeOU2xcjyKmwb/37Ef2pYEgfYgmjerCSpc3DMMMLyXU=; b=VyqMBqPR1LoaiEtQeGS8zMBkrBXhEJe1cwyVSu1d87U6OKPM85Ucupqqf9FEJU2Ptu qDJvztJ32bp66iqha7EzDBhfmbED6NGkWbDoe/qetFMJz1Xh/Fm0aqDobYsjUo2i1z49 gSzGrG848+j9lKjiVSEm1mJyuMBKHI85pqLcmKezq8wJuEI5bCg+vcjC3yJ+jVNgWiez l+WN3ZKJxfwQLXgyHzVhdUf+DGLNTklrJrVn09Q7S6qQwi+5BaYv4ahaYn9kbRxuGmGG /Sm3CbegWbnWXH8Xjdb0zrgtBSgRV+jmkujXEcVpa5MsOjCRHnAu7YGQ28313H4YnMW8 vkwA== X-Received: by 10.28.57.69 with SMTP id g66mr11706964wma.63.1450565844429; Sat, 19 Dec 2015 14:57:24 -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::22b 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:196538 Archived-At: --001a1148e710e2f9230527482d93 Content-Type: multipart/alternative; boundary=001a1148e710e2f91c0527482d91 --001a1148e710e2f91c0527482d91 Content-Type: text/plain; charset=UTF-8 Philipp Stephani schrieb am Sa., 19. Dez. 2015 um 22:03 Uhr: > 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. > Added another patch that documents some of the assumptions about non-local exits. I've added them directly to lisp.h so that people changing these definitions will hopefully notice. --001a1148e710e2f91c0527482d91 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Philip= p Stephani <p.stephani2@gmail.c= om> schrieb am Sa., 19. Dez. 2015 um 22:03=C2=A0Uhr:
Philipp Stephani <p.stephani2@gmail.com> schrieb am Sa., 28. Nov. 2015= um 11:58=C2=A0Uhr:
Eli Zaretskii <eliz@gnu.org> schrieb am Fr., 27. Nov. 2015 um 08:36=C2=A0Uhr:
=
> Cc: emacs-devel@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 custom error handling= with signals. The signals will be immediately caught by the prologue, but = some complexity and duplication is removed.=C2=A0

Added another patch that documents some of the ass= umptions about non-local exits. I've added them directly to lisp.h so t= hat people changing these definitions will hopefully notice.=C2=A0
--001a1148e710e2f91c0527482d91-- --001a1148e710e2f9230527482d93 Content-Type: application/octet-stream; name="0001-Document-assumptions-about-non-local-exits.patch" Content-Disposition: attachment; filename="0001-Document-assumptions-about-non-local-exits.patch" Content-Transfer-Encoding: base64 Content-ID: <151bc760b3c1386d4821> X-Attachment-Id: 151bc760b3c1386d4821 RnJvbSA1MjVmZWM4NTMyODlkZmZjYWJiMzEzNjA1ZGE3MjYyZGExZjhjY2VmIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBQaGlsaXBwIFN0ZXBoYW5pIDxwaHN0QGdvb2dsZS5jb20+CkRh dGU6IFNhdCwgMTkgRGVjIDIwMTUgMjM6NTE6NTIgKzAxMDAKU3ViamVjdDogW1BBVENIXSBEb2N1 bWVudCBhc3N1bXB0aW9ucyBhYm91dCBub24tbG9jYWwgZXhpdHMuCgoqIGxpc3AuaDogRG9jdW1l bnQgYXNzdW1wdGlvbnMgYWJvdXQgRVEgYW5kIE5JTFAuCgoqIGVtYWNzLW1vZHVsZS5jIChtb2R1 bGVfbm9uX2xvY2FsX2V4aXRfZ2V0KTogRG9jdW1lbnQgdGhhdCB3ZQpjYW5ub3QgdXNlIHRoZSBj dXJyZW50IGltcGxlbWVudGF0aW9uLgoobW9kdWxlX2lzX25vdF9uaWwsIG1vZHVsZV9lcSk6IERv Y3VtZW50IGFzc3VtcHRpb25zIGFib3V0IEVRIGFuZApOSUxQLgotLS0KIHNyYy9lbWFjcy1tb2R1 bGUuYyB8IDggKysrKysrLS0KIHNyYy9saXNwLmggICAgICAgICB8IDkgKysrKysrKystCiAyIGZp bGVzIGNoYW5nZWQsIDE0IGluc2VydGlvbnMoKyksIDMgZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0 IGEvc3JjL2VtYWNzLW1vZHVsZS5jIGIv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