From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lynn Winebarger Newsgroups: gmane.emacs.devel Subject: Re: native compilation units Date: Sat, 11 Jun 2022 13:49:13 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f6025e05e12fac92" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21941"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Andrea Corallo , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 11 20:20:25 2022 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 1o05ii-0005bd-Sc for ged-emacs-devel@m.gmane-mx.org; Sat, 11 Jun 2022 20:20:25 +0200 Original-Received: from localhost ([::1]:55684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o05ih-0001my-N6 for ged-emacs-devel@m.gmane-mx.org; Sat, 11 Jun 2022 14:20:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o05Em-0004tC-T7 for emacs-devel@gnu.org; Sat, 11 Jun 2022 13:49:28 -0400 Original-Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]:37840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o05Ek-0004aq-Rs for emacs-devel@gnu.org; Sat, 11 Jun 2022 13:49:28 -0400 Original-Received: by mail-lf1-x12d.google.com with SMTP id h23so3043067lfe.4 for ; Sat, 11 Jun 2022 10:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EriTceXn0+vZWOP8fP8OBGXa5gGOzP9tp5YgE1oBxx4=; b=Hl1uOEJqNOSUyYgiU+hoo/CZ68o8umtWWIWqfo1zE5v8Su1VNu2hKqABW0ut51lmV8 iSSBT+2Z9RGWhYsn+piQctwyQzworDKb4zEvJ4WMd4LCbpeAJ9ZGmlUKgTcGgyr3yMpZ qcc2SKIci0GW6m1b5G2on126czpaxcxqjs41vUY1zRnd/7qWRup8Jv7Wd0m2VCdyWL/A 7dSizAuZZpWNlqbJ0vqOkv7auWkNvo4djOWQVRPkCGZZXYsUrY1FFJvIIMwqFIWQf8Bs c7D2a2+w853G2Z9W2cGoetv4fKH92KxonW98jIGAlRR8LU9+YC5/VBeM0ZvNMyRmxHl4 ltVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EriTceXn0+vZWOP8fP8OBGXa5gGOzP9tp5YgE1oBxx4=; b=SsDJcwl6rQs8gwQpfNDUQ/tfrBIHaukkw7gmd62V2cTOPzf775RD/qWeazEZ8lLJkW xq5ygyGlfQPGu6N56rnP+2QeNS6w4HENJ6jaz6zWiJExkSqWQbKivh00SA5TZJTgz493 QfCEmhLiw9wDlvM72SXke0mtyLNFgNmKrIHeGFA3WalveU1wQdFSuc03SBMUd7KJdQDv W7cTIIXEF15zGlER1ZkWd2f7bSaGCnC7cAcTJKHqGVQnDDHY8OdULmbGoQMjo82t1arZ QdQ6OiMhOpmsnlGX4jODl4xslwxWA5K+FozKFRYgETR6PkE4pFoBL9KBrMhbG26X8RAI YYaw== X-Gm-Message-State: AOAM532Gy40/zojw5duaaYTRo5aZxpWnimWwsPu9ZumDjIb72mVHkpq4 wihP/aHyXXMFqhydleH7Vp+ayw3J88eN35dbGRY= X-Google-Smtp-Source: ABdhPJxq2hPdKe9uPwaYxFgH5S18H8pU82Wn05ofehSO1dhYU/L4LY7Rh/ZOW/eSboiY2xUUpuQLhr6NjQ9FURo83yU= X-Received: by 2002:a05:6512:3c82:b0:479:4df2:c58 with SMTP id h2-20020a0565123c8200b004794df20c58mr17966192lfv.276.1654969765067; Sat, 11 Jun 2022 10:49:25 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::12d; envelope-from=owinebar@gmail.com; helo=mail-lf1-x12d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 11 Jun 2022 14:19:32 -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" Xref: news.gmane.io gmane.emacs.devel:291045 Archived-At: --000000000000f6025e05e12fac92 Content-Type: text/plain; charset="UTF-8" On Sat, Jun 11, 2022 at 12:37 PM Stefan Monnier wrote: > > Would it make sense to add a feature for declaring a function symbol > value > > is constant and non-advisable, at least within some notion of explicitly > > named scope(s)? That would allow developers to be more selective about > > which functions are "exported" to library users, and which are defined as > > global function symbols because it's more convenient than wrapping > > everything in a package/module/namespace in a giant cl-flet and then > > explicitly "exporting" functions and macros via fset. > > In which sense would it be different from: > > (cl-flet > ... > (defun ...) > (defun ...) > ...) > > Good point - it's my scheme background confusing me. I was thinking defun would operate with similar scoping rules as defvar and establish a local binding, where fset (like setq) would not create any new bindings. (1) I don't know how much performance difference (if any) there is between (fsetq exported-fxn #'internal-implementation) and (defun exported-fxn (x y ...) (internal-implementation x y ...)) (2) I'm also thinking of more aggressively forcing const-ness at run-time with something like: (eval-when-compile (cl-flet ((internal-implemenation (x y ...) body ...)) (fset exported-fxn #'internal-implementation))) (fset exported-fxn (eval-when-compile #'exported-fxn)) If that makes sense, is there a way to do the same thing with defun? Or perhaps cl-labels instead of cl-flet, assuming they are both optimized the same way. Lynn --000000000000f6025e05e12fac92 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sat, Jun 11, 2022 at 12:37 PM Stefan M= onnier <monnier@iro.umontrea= l.ca> wrote:
>=C2=A0 Would it make sense to add a fe= ature for declaring a function symbol value
> is constant and non-advisable, at least within some notion of explicit= ly
> named scope(s)?=C2=A0 That would allow developers to be more selective= about
> which functions are "exported" to library users, and which a= re defined as
> global function symbols because it's more convenient than wrapping=
> everything in a package/module/namespace in a giant cl-flet and then > explicitly "exporting" functions and macros via fset.

In which sense would it be different from:

=C2=A0 =C2=A0 (cl-flet
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ...
=C2=A0 =C2=A0 =C2=A0 (defun ...)
=C2=A0 =C2=A0 =C2=A0 (defun ...)
=C2=A0 =C2=A0 =C2=A0 ...)


Good poin= t - it's my scheme background confusing me.=C2=A0 I was thinking defun = would operate with similar scoping rules as defvar and establish a local bi= nding, where fset (like setq) would not create any new bindings.
= (1) I don't know how much performance difference (if any) there is betw= een
=C2=A0 =C2=A0 =C2=A0(fsetq exported-fxn #'internal-implem= entation)
and
=C2=A0 =C2=A0 =C2=A0(defun exported-fxn (= x y ...) (internal-implementation x y ...))

(2) I&= #39;m also thinking of more aggressively=C2=A0forcing const-ness at run-tim= e with something like:
(eval-when-compile
=C2=A0 (cl-fl= et ((internal-implemenation=C2=A0(x y ...) body ...))
=C2=A0 =C2= =A0 =C2=A0(fset exported-fxn #'internal-implementation)))
(fs= et exported-fxn (eval-when-compile #'exported-fxn))

If that makes sense, is there a way to do the same thing with defun?<= /div>
Or perhaps cl-labels instead of cl-flet, assuming they are both o= ptimized the same way.

Lynn

--000000000000f6025e05e12fac92--