From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: Replace trivial pcase occurrences in the Emacs sources Date: Tue, 30 Oct 2018 15:56:33 -0400 Message-ID: <87231bd6-d4a3-e117-06b9-774ec482d62f@gmail.com> References: <86mur137n8.fsf@gmail.com> <20181029130132.GB4195@ACM> <20181029134722.GC4195@ACM> <83r2g8klf9.fsf@gnu.org> <9bfd9d19-3b6b-57cd-50a0-24660707768b@gmail.com> <20181030181434.GB5705@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1540929702 6077 195.159.176.226 (30 Oct 2018 20:01:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2018 20:01:42 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 30 21:01:38 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 1gHaCm-0001Ro-J3 for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 21:01:36 +0100 Original-Received: from localhost ([::1]:55288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHaEt-0003El-5j for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 16:03:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHa87-0005e7-1l for emacs-devel@gnu.org; Tue, 30 Oct 2018 15:56:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHa83-0006oS-MP for emacs-devel@gnu.org; Tue, 30 Oct 2018 15:56:46 -0400 Original-Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:47031) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHa81-0006bW-SY for emacs-devel@gnu.org; Tue, 30 Oct 2018 15:56:42 -0400 Original-Received: by mail-qk1-x733.google.com with SMTP id q1so6375926qkf.13 for ; Tue, 30 Oct 2018 12:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=vK3ONC+RvCNJM7QkeGk+qUQ0gTDN6I5pQltAZMQcWHg=; b=J35/32455uC/rWLiQXqV8cQl+2e4eyX9U0lNCw7oE3UIPPiP//Dv2i9ixOOtp/Ofox 1S4HUuRyeIocqMjjru9wdvZ1SagPzbZyjKb/LNjOatcKY6j5ZbYtklzKOxQ2kFlXD3Y7 qjLH06SU/MfvsiEZnT2WH052rB5D65gnI5RSO4NQs39l7x8wjoafLnWCgx6nOLUcynQu cM80ZXz8sTFNtz2WfztF26S+BpO8O81XC+mGzm9ne78T/nT9t/r222fiCmKE8Bc/1AbT wfXmowMxt00/O4ChKh4hyAIzTgWK7clPmeyhdcfppuYpRFiisoZRUhG95DozfYHBPIDk Un4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vK3ONC+RvCNJM7QkeGk+qUQ0gTDN6I5pQltAZMQcWHg=; b=RPVWydGifLDh8gSXGuhN93BP82avGgJBy0exVofhAeMSW7tv2RHHPrlzf1xyUOAlYN kZaO65bGZf0Ujo4D+EO7zIKbPbxBAjVvwms/5sTJvUebrcNSMaiWZUSB0efgHgI8I8hJ arly/xExsKlqBpLQ++sBCUZS2hptofEDOYgRFI/A7jEVS/DWgWbmy6h8wFHJonxqN3jg CS7OKR8xvbVyQoDS1fcllJxTRa5qaEDcWpcFl5DCrgz7k/W1mznEz8zWRA1jjiiDiCXm gW6wsb5ZOXts6lW/MWS2q7F22G2wLJ2UOnmOUGnxYa3/7MzvgzsGUecHdBybScNXF+cR KAwQ== X-Gm-Message-State: AGRZ1gInKOrBNGBHe12MkyqrRLAdudB8IuaKGoMe8j3FkPdhaFzwwVv3 xylbPpgTQM+bIHyJb+nORVsO4wET X-Google-Smtp-Source: AJdET5eA2EyFrt1iUzHYuNDVXxBXY/V/F6hVSr0XmpzmOLxZiyfGdgp0sAouyP9b/Z6hcGR8m8zO5Q== X-Received: by 2002:a37:1054:: with SMTP id a81mr111594qkh.150.1540929394693; Tue, 30 Oct 2018 12:56:34 -0700 (PDT) Original-Received: from [18.26.2.123] (26-2-123.dynamic.csail.mit.edu. [18.26.2.123]) by smtp.gmail.com with ESMTPSA id l14-v6sm16668504qtk.97.2018.10.30.12.56.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 12:56:34 -0700 (PDT) In-Reply-To: <20181030181434.GB5705@ACM> Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::733 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:230852 Archived-At: On 30/10/2018 14.14, Alan Mackenzie wrote: > Hello, Clément. Hey Alan :) > On Tue, Oct 30, 2018 at 11:05:55 -0400, Clément Pit-Claudel wrote: >> On 30/10/2018 10.16, Andy Moreton wrote: >>> How are users meant to write reliable code using such constructs ? > >> Ensure that the pattern actually matches :) > > You mean, unless you can be 100% sure that the pattern will match, you > mustn't use pcase-... constructs. That sounds equivalent to saying you > shouldn't use these constructs at all. That's an odd conclusion. >> IOW, only use these constructs when it's an invariant of your program >> that the pattern will match the data. For cases in which the pattern >> might not match, use pcase instead of pcase-dolist. > > pcase is not a looping construct. pcase-dolist is. They're not > replacements for eachother. I should have written "use `pcase' with `dolist` instead of `pcase-dolist'". Concretely, replace this: (pcase-dolist (pat list) …) with this: (dolist (xyz list) (pcase xyz (pat …) (_ (handle-error-here))))