From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Adam Porter Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] pcase.el: Add type pattern Date: Mon, 09 Mar 2020 14:31:27 -0500 Message-ID: <87r1y1wcj4.fsf@alphapapa.net> References: <874kuxxuez.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="22733"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 09 20:33:02 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 1jBO97-0005oX-Ul for ged-emacs-devel@m.gmane-mx.org; Mon, 09 Mar 2020 20:33:01 +0100 Original-Received: from localhost ([::1]:48586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBO96-0003fM-VZ for ged-emacs-devel@m.gmane-mx.org; Mon, 09 Mar 2020 15:33:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51844) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBO7p-0002l9-JA for emacs-devel@gnu.org; Mon, 09 Mar 2020 15:31:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBO7o-000758-IM for emacs-devel@gnu.org; Mon, 09 Mar 2020 15:31:41 -0400 Original-Received: from ciao.gmane.io ([159.69.161.202]:36164) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBO7l-00073D-6c for emacs-devel@gnu.org; Mon, 09 Mar 2020 15:31:40 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jBO7j-00048f-7u for emacs-devel@gnu.org; Mon, 09 Mar 2020 20:31:35 +0100 X-Injected-Via-Gmane: http://gmane.org/ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 159.69.161.202 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:245405 Archived-At: Stefan Monnier writes: >> I wondered if checking for predicates like this was a good way to do >> so, > > `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. :) >> + (pred (or (intern-soft (concat type "p")) >> + (intern-soft (concat type "-p")) > > This fails for those cl-defstructs where the `:predicate` was given > another name (or no name at all). Good catch, thanks. > 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. > PS: Arguably, every type symbol should have a corresponding *class* > (currently stored in the `cl--class` symbol for cl-defstruct and eieio > objects), so we should then add a bunch of classes for non-structs > non-eieio types (such as integer, ...) and we could then define a > generic function which takes such a class and returns the predicate to > use as a test for this type. Seems like a good idea to me, although the scope of those changes seem much larger than this patch, and I'm not sure I'm the right person for that job. Thanks for your feedback.