From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Garreau\, Alexandre" Newsgroups: gmane.emacs.devel Subject: Re: pcase ` meaning Date: Thu, 01 Nov 2018 00:13:42 +0100 Message-ID: <87wopxr9p5.fsf@portable.galex-713.eu> References: <20151216202605.GA3752@acm.fritz.box> <56895FDE.4060406@yandex.ru> <8760za8r4a.fsf@fencepost.gnu.org> <87h9iunkcg.fsf@web.de> <87h8hc4xw2.fsf_-_@web.de> <83tvlcsnee.fsf@gnu.org> <87pnw037ar.fsf@web.de> <83ftwvs7y9.fsf@gnu.org> <877ei7mkfh.fsf@web.de> <87a7mze7tl.fsf@web.de> <87zhuykjjh.fsf@web.de> <871s8aesdc.fsf@portable.galex-713.eu> <87tvl6dc3e.fsf_-_@portable.galex-713.eu> <87efc9isxj.fsf@web.de> <87tvl5653j.fsf@portable.galex-713.eu> <38aa830d-740e-af4d-9071-9aa0d9c10f04@gmail.com> <87efc8qnwh.fsf@portable.galex-713.eu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1541027559 22687 195.159.176.226 (31 Oct 2018 23:12:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 31 Oct 2018 23:12:39 +0000 (UTC) User-Agent: Gnus (5.13), GNU Emacs 25.1.1 (i686-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-09-15, modified by Debian Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 01 00:12:35 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 1gHzf7-0005jC-Cf for ged-emacs-devel@m.gmane.org; Thu, 01 Nov 2018 00:12:33 +0100 Original-Received: from localhost ([::1]:33973 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHzhD-00042x-Kq for ged-emacs-devel@m.gmane.org; Wed, 31 Oct 2018 19:14:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHzgM-00041m-9I for emacs-devel@gnu.org; Wed, 31 Oct 2018 19:13:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHzgL-0006DO-Ka for emacs-devel@gnu.org; Wed, 31 Oct 2018 19:13:50 -0400 Original-Received: from portable.galex-713.eu ([2a00:5884:8305::1]:46042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHzgL-0006B9-Au for emacs-devel@gnu.org; Wed, 31 Oct 2018 19:13:49 -0400 Original-Received: from localhost ([::1] helo=portable.galex-713.eu) by portable.galex-713.eu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHzgE-0003ms-RE; Thu, 01 Nov 2018 00:13:42 +0100 PGP-FINGERPRINT: E109 9988 4197 D7CB B0BC 5C23 8DEB 24BA 867D 3F7F Accept-Language: fr, en, eo, it, br In-Reply-To: (Stefan Monnier's message of "Tue, 30 Oct 2018 09:14:41 -0400") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:5884:8305::1 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:230924 Archived-At: On 2018-10-30 at 09:14, Stefan Monnier wrote: >> #+BEGIN_SRC ocaml >> match [1;2;3] with [a;b;c] -> [a;b;c] >> #+END_SRC >> >> But this is a non-primordial side effect. Notice how in the later case >> the matched data *always* look the same as the pattern (beside replacing >> a number per an identifier): *that=E2=80=99s* the purpose of pattern mat= ching. >> While in the lisp case you got those extra =E2=80=9C,=E2=80=9D. > > That's for a very simple reason: OCaml doesn't have Lisp's symbols, so > its [a;b;c] can't mean "a list containing the symbols a, b, and c". In lisp I would have prefered to be able to directly quote each symbol, and have this to work, eg: =E2=80=9C(pcase (list 1 2 3) (('a 'b 'c) t))=E2= =80=9D to return nil, and =E2=80=9C(pcase (list 'a 'b 'c) (('a 'b 'c) t))=E2=80=9D to= return t (and this is like many other lisp pattern-matching implementations already work). In current pcase, pattern =E2=80=9C(a b c)=E2=80=9D does *n= ot* mean =E2=80=9Cwith symbols 'a, 'b and 'c=E2=80=9D. =E2=80=9C('(a b c) t)=E2=80=9D (or same with =E2=80=9C`=E2=80=9D) seems oka= y to me, but as =E2=80=9C(`(,a ,b ,c) t)=E2=80=9D *may* be confusing (the intended, actual and current meaning mu= st be intuitive under some definition of =E2=80=9Cintuitive=E2=80=9D too since ot= hers independantly do it too), I=E2=80=99d prefer =E2=80=9C((a b c) t)=E2=80=9D = to work. > OCaml still has to distinguish between variables and data constructors, > but instead of using a "," to distinguish the two cases, they force > constructors to be capitalized. Oh=E2=80=A6 yet another (disappointing) reason why they did what (incredibly limited) they did (though afaik it=E2=80=99s nothing new, it have to come f= rom Smalltalk, and I=E2=80=99m not that much opposed to identifiers names/meani= ng intermeddling).