From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Declaring Lisp function types Date: Thu, 02 May 2024 09:15:34 +0300 Message-ID: <8634r0oi2h.fsf@gnu.org> References: <8634sdjgoj.fsf@gnu.org> <86mspaq4ro.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31339"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org, stefankangas@gmail.com, adam@alphapapa.net, arthur.miller@live.com To: Andrea Corallo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu May 02 08:16:50 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s2PkQ-0007ve-1b for ged-emacs-devel@m.gmane-mx.org; Thu, 02 May 2024 08:16:50 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2Pjp-0001Lg-4s; Thu, 02 May 2024 02:16:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2PjT-0001Di-DC for emacs-devel@gnu.org; Thu, 02 May 2024 02:15:53 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2PjS-0008OO-8K; Thu, 02 May 2024 02:15:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=eD3THIqGH8cXsZBwOKmrBV8HrR4dMUOhb0DKYNyrw/M=; b=cwkxqdSOsS/8 cuKgTN8RHV3u/zhKDf8JjCsTRjTi62OCZkbfmcCWcE+anBB8LQkQ/lAW+RxV7NuBIFhdBdSdopLoA oR64Q7JSTxwS73mx9I+yhcHkiUXONMAYj5v5gk9yaamUlmWGz1uh/m5IGRT2lQc8Ld3eStSmu6ThG FxYHaweEhrGSogAW09gpT9NXAYZaLRMI3z7RjlcRFJHuaeiD77ohtyVciiOGbOoyaPYY3oKQsJeR2 J9QLGLwYu7ItYofcNQAZ0PJi71SlYTNHfd7U0PStvSWNmxVuq+jHiMk+3tDCn9WQWE8L8WN5vShFI MBQ0wSA0KT4dbSQh39nnbQ==; In-Reply-To: (message from Andrea Corallo on Wed, 01 May 2024 16:57:58 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:318532 Archived-At: > From: Andrea Corallo > Cc: Eli Zaretskii , emacs-devel@gnu.org, > stefankangas@gmail.com, adam@alphapapa.net, arthur.miller@live.com > Date: Wed, 01 May 2024 16:57:58 -0400 > > Stefan Monnier writes: > > > Thanks Eli for reminding me: as mentioned earlier, I think we should > > clarify what are the possible consequences if a type does not faithfully > > reflect the behavior of the function. Examples of questions that one > > should be able to answer based on the doc: > > > > - Can an incorrect type affect Emacs' behavior (other than performance)? > > - And if so, can it cause a crash? > > - What if the type is/was right but an advice does > > not obey the original type of the advised function? > > > > The doc doesn't need to answer those questions directly, but it should > > describe the possible effects of type annotations in enough details that > > we can answer those questions. > > Thanks, I think it should be more clear now. I don't think we want to > be over specific there as what the implementation does when the > 'promise' of the declaration is not respected might change in the > future. The text you added says an incorrect type produces undefined behavior. Is that true for all alternatives of calling the function: interpreted, byte-compiled, and native-compiled, or only with some of these? "Undefined behavior" sounds scary, and I wonder whether it is really accurate. If the practical expressions of this UB are only some specific ones, perhaps we should mention them? For example, UB generally means your entire system could be brought down, but I very much doubt that this could happen due to incorrect type declaration, could it?