From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: master 0cbcc62: 'assoc' is not side-effect-free; constprop its pure subset Date: Sun, 01 Nov 2020 09:07:46 -0500 Message-ID: References: <20201031133156.28415.87445@vcs0.savannah.gnu.org> <20201031133158.04C1220A1C@vcs0.savannah.gnu.org> <823589BC-6CB4-4140-A442-10B5FF5870AC@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2755"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org, Andrea Corallo To: Mattias =?windows-1252?Q?Engdeg=E5rd?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 01 15:09:00 2020 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 1kZE2W-0000bD-Em for ged-emacs-devel@m.gmane-mx.org; Sun, 01 Nov 2020 15:09:00 +0100 Original-Received: from localhost ([::1]:33754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZE2V-0004rL-GL for ged-emacs-devel@m.gmane-mx.org; Sun, 01 Nov 2020 09:08:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZE1Q-0003y5-OB for emacs-devel@gnu.org; Sun, 01 Nov 2020 09:07:52 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:61493) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZE1O-00065a-7t for emacs-devel@gnu.org; Sun, 01 Nov 2020 09:07:51 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D0DEF8096B; Sun, 1 Nov 2020 09:07:48 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5B1A5808C6; Sun, 1 Nov 2020 09:07:47 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1604239667; bh=vmG9fWNgsd3VutENbf8jcS14eNZ9hvLLPDXfunf+oQM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=CIDPiSBb4jXDvj4JxJqKLGds5MihOa6+tZJvSljGUP+vxo40M6WQp0Zha+KP6RWZx emWIob8Cqt4ufelfbG1fxVi1wXcgaMbi0KOiPbh7wl6qsU2SMEQ8vZF3sVgHLjJK3q tFu9yQOuhlfjjRYzhcr8qc1suGA/xY8rxoijZWhXaRiUHjbvkbriZEPmDPDv3heWKK ko9UoiJYdJCSm9jaJerZN64DL8cc/Ssh+HkD5JkiB7DSru22GhXggXJ3LaSTrduLxW fq6ZJuzyXijnmJlCRXBE+cafjWMIeZ7MRNuofyiKstDr5lQWjgZ9N+BeOGkrCfjX1m b3uKcl26mqnbw== Original-Received: from alfajor (unknown [157.52.9.240]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2678612016D; Sun, 1 Nov 2020 09:07:47 -0500 (EST) In-Reply-To: <823589BC-6CB4-4140-A442-10B5FF5870AC@acm.org> ("Mattias =?windows-1252?Q?Engdeg=E5rd=22's?= message of "Sun, 1 Nov 2020 13:56:50 +0100") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/01 08:29:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:258601 Archived-At: > It wasn't really meant seriously, but a simple system may look like > > EFFECT ::=3D > nil ; no effect (subset of all effects) > | * ; any effect (superset of all effects) > | signal ; signal any condition (error etc) > | read-env ; read from the global environment > | N ; effect of function passed as argument N, N=E2=89=A51 > | (union EFFECT...) ; union of effects Side note: this sounds good (I've been thinking along very similar lines recently to try and improve the docs of `pure` and `side-effect-free`), but note that nil has to me "any effect" since most functions will come with no annotation at all (which most is most naturally mapped to nil). Also, there are a few functions which we're willing to constant-fold even though they can have "minor" side-effects (the cases I can think of seem to be mostly about clobbering the match-data, so maybe all it means is that we need is an additional `clobbers-match-data`, which means that the contents of the match-data can't be relied upon after the call). > More fine-grained effects could be added, such as throws, mutation of > arguments, reading data referenced by arguments, etc. If we ever want to be able to detect match-data errors via static analysis, we'd need to know which functions set the match data, which functions are guaranteed not to affect the match-data, and which functions read the match data (then we can warn any time you read the match data even though you called a function not known to preserve the match-data since the last call to a match-data-setting function). Now admittedly, "preserve the match-data" is not really an effect ;-) > It all depends on what is useful for the compiler(s) and related tools. Indeed, we should keep things as simple as possible. For me the main benefit is that it seems easier to explain those effects than to explain what it means to be "pure" or "side-effect-free", probably because both of those terms already exist in computer-English but with not 100% precise meanings and that our use doesn't match 100% either. Stefan