From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] pcase.el: Add type pattern Date: Mon, 09 Mar 2020 17:00:23 -0400 Message-ID: References: <874kuxxuez.fsf@alphapapa.net> <87r1y1wcj4.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="40256"; 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 To: Adam Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 09 22:01:32 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 1jBPWl-000AMG-Sk for ged-emacs-devel@m.gmane-mx.org; Mon, 09 Mar 2020 22:01:31 +0100 Original-Received: from localhost ([::1]:49744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBPWk-0004NS-U3 for ged-emacs-devel@m.gmane-mx.org; Mon, 09 Mar 2020 17:01:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38047) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBPVm-0003lC-8d for emacs-devel@gnu.org; Mon, 09 Mar 2020 17:00:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBPVk-0004tM-HS for emacs-devel@gnu.org; Mon, 09 Mar 2020 17:00:29 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:5586) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBPVk-0004sw-Ak for emacs-devel@gnu.org; Mon, 09 Mar 2020 17:00:28 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 14C9A10125D; Mon, 9 Mar 2020 17:00:27 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 555DA101074; Mon, 9 Mar 2020 17:00:25 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1583787625; bh=1r3u5MNnHtqGAET8gXUOFWr/BQoZNZ4J9SLm+jpUWW4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=OePw8jhwkZo0dpJdv7a/S2Pio/L/hvP+bB0PpDfVsVI6Nyi8doKGXSsHttSNbcJEh TPN4lOry53N3OptqXr0xxdn0CeivhofPPO+VvpGMrLxOUeez8RKisw0uq1X+sI1LYC sDjZOnMTocR3CvGE8ESm5KvoflGIa5Sytfhdw6Ybebi0+OikEq1Ql/1XADZWZfac96 w7fW/1+hvPjK543ejSALFg1HZM8Mag/1TyIygXE2UoC6ub8wU/DgrgzGVRkeW6aWgp aLKCX/O2Ex4R2GSTinm3twTiwfqKiDqggScXyIo6xpYae/q17DNhSDLZ58fIIxvVNO fEh6QNM8anXgQ== Original-Received: from alfajor (unknown [216.154.50.221]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C147012024D; Mon, 9 Mar 2020 17:00:24 -0400 (EDT) In-Reply-To: <87r1y1wcj4.fsf@alphapapa.net> (Adam Porter's message of "Mon, 09 Mar 2020 14:31:27 -0500") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 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:245412 Archived-At: >> `cl-typep` does it but I think it's a mistake. >> We should not rely on such heuristics when we can "do it right", >> e.g. with a property along the lines of `cl-deftype-satisfies`. > Understood, but I'm not sure exactly what you mean, as far as what I > should do in that regard. I'm not very familiar with cl-lib's > internals. :) The property `cl-deftype-satisfies` is very simple: (get 'cl-deftype-satisfies) gives you the predicate you need to call. So we could use this property or choose a new property name (without the `cl-` prefix) which works the same way. Then we need to add the corresponding list of (put ' ' ') somewhere (probably in `subr.el`, tho if we keep the `cl-deftype-satisfies` name, then it would also fit in `cl-preload.el`). >> We could circumvent the problem by expanding the (type T) check to >> to a call to `cl-typep`. > That would be fine with me, of course, but I was hesitant to use any > `cl-' functions in pcase.el since it doesn't use any and doesn't already > require `cl-lib'. Let me know if you want me to do that. Agreed, especially since cl*.el do use `pcase` nowadays, so making `pcase` use `cl-lib` can introduce some nasty bootstrapping problems. Another problem of using `cl-typep` as-is is the question whether we want to include the CL types such as `nil` (the empty type, traditionally called =E2=8A=A5 in type theory), `t` (the type of all object= s, traditionally called =E2=8A=A4 in type theory), `(integer MIN MAX)`, ... But at the same time, I can't think of a good reason why we should use a different notion of type than CL's, so I guess it does make sense to use `cl-typep` (makes the overall system simpler). To avoid the circularity, we can simply move the (pcase-defmacro type ...) outside of `pcase.el` so it can easily depend on both `pcase` and `cl-lib`. Another option is to do something like (pcase-defmacro type (ty) (require 'cl-lib) `(pred (pcase--flip cl-typep ',ty))) so `cl-lib` is only required lazily (when we actually expand a `(type TYPE)` pattern), so the bootstrapping problem shouldn't bite us as long as neither pcase.el nor cl*.el themselves use such a pattern. > Seems like a good idea to me, although the scope of those changes seem > much larger than this patch, Indeed. But it's not enormous either (it's only an addition to what we have, so there's no tricky business with backward compatibility and stuff). > and I'm not sure I'm the right person for that job. Based on the fact that it hasn't been done yet, I think we can assume that noone is "the right person for that job", but you might still be the closest there is. I'd be happy to help. Stefan