From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: pure-fns in byte-opt.el Date: Sun, 24 Sep 2017 09:26:15 -0700 (PDT) Message-ID: <0be371fd-9212-4c42-9c17-3038c0b3d8a1@default> References: <20170725020650.GA12601@holos.localdomain> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1506270392 21766 195.159.176.226 (24 Sep 2017 16:26:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 24 Sep 2017 16:26:32 +0000 (UTC) To: Philipp Stephani , Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 24 18:26:26 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dw9jc-0005AI-N4 for ged-emacs-devel@m.gmane.org; Sun, 24 Sep 2017 18:26:24 +0200 Original-Received: from localhost ([::1]:38730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dw9jk-0008KF-4T for ged-emacs-devel@m.gmane.org; Sun, 24 Sep 2017 12:26:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dw9jd-0008Im-Kj for emacs-devel@gnu.org; Sun, 24 Sep 2017 12:26:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dw9ja-0007nX-FW for emacs-devel@gnu.org; Sun, 24 Sep 2017 12:26:25 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:39949) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dw9ja-0007io-6Y for emacs-devel@gnu.org; Sun, 24 Sep 2017 12:26:22 -0400 Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v8OGQHJW007547 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 24 Sep 2017 16:26:17 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v8OGQHjM007136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 24 Sep 2017 16:26:17 GMT Original-Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v8OGQGWi014452; Sun, 24 Sep 2017 16:26:16 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6776.5000 (x86)] X-Source-IP: userv0021.oracle.com [156.151.31.71] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 156.151.31.81 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:218748 Archived-At: > A side-effect-free function is one where all of the following > is true: > - After exiting the function (whether normally or nonlocally), > the `match-data' are `equal' to the `match-data' before > entering the function. > - After exiting the function, all dynamic variables, their > default values, their symbol cells, etc., are `eq' to the > respective values before entering the function. Not sure what you intend by the "symbol cells" of dynamic variables. Do you mean only their `symbol-value' values? Or do you mean all properties of the symbols that serve as dynamic variables? Or do you perhaps mean all properties of all symbols (dynamic variable or not)? > Exceptions are variables only used for debugging/tracing, > such as `cons-cells-consed'. > - All buffer contents, markers, point values etc. are > `equal-including-properties' to their previous values. > - The same buffers and threads still exist. There are tons of other kinds of side effects possible in Lisp, of course. A "side-effect-free function" per your definition can perform any number of other such side effects. It can affect symbol properties, string properties, buffer properties, cons cells,.... What's the intended purpose of your "side-effect-free" function? If your definition of it is sufficient for that purpose then please consider using some other name for the quality you define, as it is really quite far from characterizing a side-effect-free Lisp function, i.e., far from indicating that a given Lisp function (so-called) performs no side effects. > A pure function is a side-effect-free function with the > following additional properties: > - The function recursively only accepts and returns numbers, > symbols, lists, vectors, hashtables, and strings; not > buffers or processes since they are naturally stateful. Just accepts and returns? What about modifying buffers or processes without accepting them as arguments or returning them? A Lisp function invocation exists in an environment that goes far beyond the current values and definitions of the current set of variables and functions. The behavior of such an invocation can be affected by any number of aspects of that environment, and it can (side-) effect any number of them. > - Two invocations with arguments that are pairwise > `equal-including-properties' (or, in the case of hashtables, > have keys and values that are `equal-including-properties') > will either both exit nonlocally or return values that are > again `equal-including-properties'. In Lisp, "functions" are not just about arguments and return values. Lisp is as procedural and imperative as Fortran, C, or assembler. But again, maybe your intended use of "pure" Lisp functions, following your definition, does not really require actually pure functions. If so, please consider using some other name for the quality you are calling "pure", as it is really quite far from characterizing a pure function.