From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Replace trivial pcase occurrences in the Emacs sources Date: Tue, 30 Oct 2018 23:09:15 -0400 Message-ID: References: <83tvlcsnee.fsf@gnu.org> <86mur137n8.fsf@gmail.com> <20181029130132.GB4195@ACM> <20181029134722.GC4195@ACM> <87y3aftklz.fsf@web.de> <87in1jt4ll.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1540955247 21709 195.159.176.226 (31 Oct 2018 03:07:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 31 Oct 2018 03:07:27 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 31 04:07:23 2018 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 1gHgqm-0005VZ-Ch for ged-emacs-devel@m.gmane.org; Wed, 31 Oct 2018 04:07:20 +0100 Original-Received: from localhost ([::1]:57043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHgss-0007Y3-Ja for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 23:09:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHgsj-0007Xh-OS for emacs-devel@gnu.org; Tue, 30 Oct 2018 23:09:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHgsh-00073z-5W for emacs-devel@gnu.org; Tue, 30 Oct 2018 23:09:21 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:32866) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHgsh-00071a-04 for emacs-devel@gnu.org; Tue, 30 Oct 2018 23:09:19 -0400 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w9V39FCM006863; Tue, 30 Oct 2018 23:09:15 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 74E6C6A495; Tue, 30 Oct 2018 23:09:15 -0400 (EDT) In-Reply-To: <87in1jt4ll.fsf@web.de> (Michael Heerdegen's message of "Wed, 31 Oct 2018 00:08:38 +0100") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6407=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6407> : inlines <6948> : streams <1802867> : uri <2741439> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 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:230865 Archived-At: >> LGTM, thanks. We could maybe give a hint about why, e.g. saying that >> there are no guarantees about the order and number of times they are run. > Are these the only restrictions? I think so, yes. > Are there even cases where side effects can still be relied on - > e.g. in > > #+begin_src emacs-lisp > (pcase EXPR > ((and P1 (guard (prog1 t (setq x 15))) P2) BODY1) > ...) > #+end_src > > is it legitimate to assume that x has been set to 15 if BODY1 is > evaluated (and P1 and P2 don't touch x)? Yes: pcase doesn't look inside the `guard`s so in order to get to BODY1 it had to evaluate `(prog1 t (setq x 15))` at some point. But some of the preds and guards of other branches (both before and after the one of BODY1) may also be run before getting to BODY1. Stefan