From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Aaron Ecay Newsgroups: gmane.emacs.devel Subject: Re: New jrpc.el JSONRPC library Date: Wed, 23 May 2018 18:57:23 +0100 Message-ID: <87r2m26yrg.fsf@gmail.com> References: <87lgcrqgvz.fsf@gmail.com> <831seipvdb.fsf@gnu.org> <871se9lyid.fsf_-_@gmail.com> <87d0xqs56o.fsf@gmail.com> <87d0xp5e5o.fsf@gmail.com> <877enx5b3j.fsf@gmail.com> <87tvr04ymv.fsf@gmail.com> 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 1527098132 27655 195.159.176.226 (23 May 2018 17:55:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 23 May 2018 17:55:32 +0000 (UTC) User-Agent: Notmuch/0.26 (https://notmuchmail.org) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: emacs-devel@gnu.org To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 23 19:55:28 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 1fLXyv-00073v-UM for ged-emacs-devel@m.gmane.org; Wed, 23 May 2018 19:55:26 +0200 Original-Received: from localhost ([::1]:34818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLY13-0005pc-07 for ged-emacs-devel@m.gmane.org; Wed, 23 May 2018 13:57:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLY0w-0005pM-KW for emacs-devel@gnu.org; Wed, 23 May 2018 13:57:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLY0t-0006W0-H1 for emacs-devel@gnu.org; Wed, 23 May 2018 13:57:30 -0400 Original-Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:35234) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fLY0t-0006VO-9z for emacs-devel@gnu.org; Wed, 23 May 2018 13:57:27 -0400 Original-Received: by mail-wr0-x22d.google.com with SMTP id i14-v6so28075022wre.2 for ; Wed, 23 May 2018 10:57:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-transfer-encoding; bh=oCGMfxpTK76pzYj4/bAxtywd13WkDWPhqwXNxSpXzoo=; b=ognZ/H0hxQQrD1dkCfy2WSqvQNxTVyIsisSp2sVKijeggw42V4RpNb3RQmFtf4dWb0 jvoRVpfeWRM5mOSKInj6xLlsNJO694E2QHTx7/5POzeHSk7kJvPmUGBcG6Kee1RsuJyo DWXosSlxxNyDWKq++/lVqt1VndL5IWSQKMKDb/kykvMfcEVJclvr2Ip2/9jIkc6/ugg+ kgwPlz62LINoCSdnRx7xmKl872YRV39BZc/h+Jr4nTS6FcZCc1sjx6JKbypKnBV4Pv/C eShBp5xrlATOt8HWVQt6JmM5q32QfQcL+p3GVjXzAbg6GdUEorD2neM6tZAtodcUrgIV 9pTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-transfer-encoding; bh=oCGMfxpTK76pzYj4/bAxtywd13WkDWPhqwXNxSpXzoo=; b=rKejdfR3fJ0owhESTRNn/zHb3xRbuzJpiPArLNB0F7wYC/ZsRr9Tw2pRhBgZT7+X4u +nVmx2VzL6U+VsSHOXqYQxjRxRWCh4IoMIROIaWE4cXP3LIkzQzW3Vd1bUYZHpBj6QKW BDubyGmGW4IiAZkQeKgXKJj2SbJ7Sl8oa46N7Enhe8oiUSlXMERmfV0VQmkimedJx5jd 6tDGzYqeHWVPmWIVXe0BzoM8oWP5NcYDAokGVsWTyb18JqCmb92BjuWGv2BtW2HqSP1h 12nxfXcQil+odGBZZS6G/dZsuKbM/nEny1xXExYbMrhQHFKd8BMOoXnPbZBMT1aUpeg1 FTkA== X-Gm-Message-State: ALKqPweIR31lpFhdGqXcUeqO+S0ydSrhhdaiZtfdUY3+CnmMMvCkdN1f HmIDG2ArMC/iY+gfxBRESKg= X-Google-Smtp-Source: AB8JxZqOIECMZx+ApARDBT1OyL+fxHR6AKbRLU6Zh0N83qNthel3s44GsqKzv+PSoIcSfTpi1RwFDA== X-Received: by 2002:adf:f60a:: with SMTP id t10-v6mr1939721wrp.97.1527098245867; Wed, 23 May 2018 10:57:25 -0700 (PDT) Original-Received: from localhost (host-78-145-166-130.as13285.net. [78.145.166.130]) by smtp.gmail.com with ESMTPSA id 131-v6sm5234524wms.34.2018.05.23.10.57.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 May 2018 10:57:25 -0700 (PDT) In-Reply-To: <87tvr04ymv.fsf@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22d 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:225621 Archived-At: Hi Jo=C3=A3o, 2018ko maiatzak 21an, Jo=C3=A3o T=C3=A1vora-ek idatzi zuen: > No, not "minus those keys", those keys are included in the &rest var > too. In that case, Stefan=CA=BCs reply tells you how to get the equivalent. >=20 >=20 > Hmm: >=20 > 1. Not particularly readable for someone that encounters the second > form. Can one M-. from map-and-rest into the defmacro to learn what > it is doing? No, but the docstrings of all the pcase-defmacros are automatically included in the docstring of pcase (the main entry point). Of course, the pcase-defmacro I wrote didn=CA=BCt have a docstring because it was just= a quick proof of concept. > > 2. The absence of control over &allow-other-keys is a big minus. It's > very useful to a) check that the object isn't providing an unknown > key, or to check that you haven't mistyped a key name. Can you > code it into the pcase-defmacro? It=CA=BCs possible to do so, but I think it would be more perspicuous to ha= ve the validation and destructuring separate. One might want to assert that the record contains some field X, without caring what X=CA=BCs value is (and thus, not needing to bind X to a lisp variable). > 3. Also can you code the more complex capabilities of &key into there? >=20 > ;; default values > (cl-destructuring-bind (&rest rest &key (foo "default") bar) nil > (list foo bar)) ;; -> ("default" nil) >=20 > ;; provided-p > (cl-destructuring-bind (&rest rest &key (foo nil foo-provided-p) bar) > '(:bar nil :foo nil) > (list foo bar foo-provided-p)) ;; -> (nil nil t) >=20 > ;; alias > (cl-destructuring-bind (&rest rest &key > ((:extremely-long-foo-with-the-airplane foo)) bar) > '(:extremely-long-foo-with-the-airplane 42) > (list foo bar)) ;; -> (42 nil) Again one could, but I personally don=CA=BCt see the advantage of (foo nil foo-provided-p) over (memq 'foo (map-keys my-alist)). Anyway, I first pointed out the possibility of using pcase because I understood you to be saying that the features of cl-destructuring-bind+plist were not easily replicated by anything+alists. I hope to have shown that those features are indeed available. It=CA=BCs still up to you if you are satisfied by the minutiae;= I just didn=CA=BCt want you to labor under the misconception that there are no alternatives. :) >=20 > I think clients of jsonrpc.el should be able to use whatever they want > to destructure JSON (though I recommend plists and I think it should be > the default datatype passed to the dispatcher).=20 Indeed, json.el in emacs core has the json-object-type variable to control the plist-vs-alist-ness of decoded JSON. Maybe your library can also work with that variable? --=20 Aaron Ecay