From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#40693: 28.0.50; json-encode-alist changes alist Date: Fri, 22 May 2020 15:54:33 +0100 Message-ID: <87sgfs81g6.fsf@tcd.ie> References: <87a738jotd.fsf@tcd.ie> <87mu6utxd1.fsf@tcd.ie> <83r1w6ziql.fsf@gnu.org> <82572c3f-fb24-0b01-06ec-47067d9219ca@yandex.ru> <83blnazdly.fsf@gnu.org> <87wo5yqrqo.fsf@tcd.ie> <87ftbyavbq.fsf@tcd.ie> <87zha43ira.fsf@gmail.com> <87367t9ej7.fsf@tcd.ie> <87imgp2atd.fsf@gmail.com> 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="106186"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: darthandrus@gmail.com, 40693-done@debbugs.gnu.org, Dmitry Gutov To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 22 16:55:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1jc94q-000RPm-3s for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 May 2020 16:55:12 +0200 Original-Received: from localhost ([::1]:40940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jc94p-0001Av-1Q for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 May 2020 10:55:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jc94h-000190-1m for bug-gnu-emacs@gnu.org; Fri, 22 May 2020 10:55:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48471) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jc94g-0006Fl-Ob for bug-gnu-emacs@gnu.org; Fri, 22 May 2020 10:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jc94g-0002DQ-Ns for bug-gnu-emacs@gnu.org; Fri, 22 May 2020 10:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 May 2020 14:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40693 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed patch Original-Received: via spool by 40693-done@debbugs.gnu.org id=D40693.15901592848463 (code D ref 40693); Fri, 22 May 2020 14:55:02 +0000 Original-Received: (at 40693-done) by debbugs.gnu.org; 22 May 2020 14:54:44 +0000 Original-Received: from localhost ([127.0.0.1]:60012 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jc94O-0002CK-2K for submit@debbugs.gnu.org; Fri, 22 May 2020 10:54:44 -0400 Original-Received: from mail-qt1-f195.google.com ([209.85.160.195]:42927) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jc94M-0002C0-CY for 40693-done@debbugs.gnu.org; Fri, 22 May 2020 10:54:42 -0400 Original-Received: by mail-qt1-f195.google.com with SMTP id x12so8437834qts.9 for <40693-done@debbugs.gnu.org>; Fri, 22 May 2020 07:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=wQXLa00oL3CFCiIrAB1UF9R/hwSULi+3PUrwW6UwRr8=; b=SgCvey7tM4J84t8xqmikwWlFXiUaF5ZLWxk5SNvhJv6pDcST0vmLOLqeg7zIKpsXyv ogbqUt9uNJIVHWARTiPzgF04ei4eLZcK3cmjP9fnprF4HX+6FiVCojN6KDJFug076ipQ IOBe2WKQuxfEQZpQvsXsg0tDgJVyUQ06376vl5zCQoj19sx3PwgngRqEqpK9BPaqBIGh las1Aom8CNw42/ikB8C/6XVLnr98xUmKiD7GwQ7NBRcV31OPguu8hDa+Rm73ozVY32Wk RrCncCfBUgsB2eNIjui09jME2sPK/Olwhd7hfZpwUpdjDHyIrI4ieFryDpQ5nGh2irXW v6Ow== 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:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=wQXLa00oL3CFCiIrAB1UF9R/hwSULi+3PUrwW6UwRr8=; b=dJkzfrC4fQYt8XckGe4GY2Hw6Jy4sGoTPrWvLMQB0CGbP9PeEGgNY67CTOxjBqhhLp LvOqTK7ERGfWcqc4z1RuwwmZ8ibKif8flMXrElo3grRLTFSV1QdEaxNmb0YJnymbVsPp YUywE1Ax5902Bm/7CDtrVHGBqj6890AdGhmIIWN6A/mUklhNU5dNHSODHy2X7RDsFAg7 +Nuz8K3jPo3asOud2m9hS5bp5otjoC7BJ+PDy/QkjXXtgpG8NdX4gEjUxO4TiTE0+9+e xyLeUYjA5eJ5xPjIYfRBg+fbhVS+UnTs5wFUHV3YSQvtnQVPpwTUbUGihL/iPfjtkoqA fePA== X-Gm-Message-State: AOAM531ILH67FojB0/CD3fJfHRLZcvW37bwR5eT/rWFv1A+PT+q3ppCz j0mH628t72hxZhSGa5xA6vOuow== X-Google-Smtp-Source: ABdhPJxMzElPZGbPInFmcOspylA7BwieWbe7JIb00j0oqE+52QyH0/2e0eF6Xfr54RLZGLJrONIOYQ== X-Received: by 2002:aed:37ca:: with SMTP id j68mr16233530qtb.276.1590159276549; Fri, 22 May 2020 07:54:36 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id l64sm7115419qkd.15.2020.05.22.07.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 07:54:35 -0700 (PDT) In-Reply-To: <87imgp2atd.fsf@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Thu, 21 May 2020 23:16:30 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:180774 Archived-At: tags 40693 fixed close 40693 28.1 quit Jo=C3=A3o T=C3=A1vora writes: > "Basil L. Contovounesios" writes: >> The declarations are needed because the byte-compiler does not know that >> loading json.el will e.g. define a dynamically bound variable >> json-object-type and a nullary function symbol json-read. It therefore >> not only complains but also generates invalid byte-code. > > Basil, I understand the need for the declarations, but I was suggesting > something different. This, at the top, near all the other requires. > > (eval-and-compile > (unless (fboundp 'json-parse-buffer) > (require 'json))) > > and then do the defalias without the declarations below. > > (defalias blabla > (if (fboundp 'json-parse-buffer) > (lambda () json-c-things...) > (lambda () json-el-things...))) > > Am I missing something or doesn't this work like you want? There's a problem with the conditional require at byte-compile time. If the version of Emacs doing the byte-compilation has native JSON support, then it will generate invalid byte-code (and complain) for the case where there is no native JSON support. In other words, there will be a bug when an Emacs without native JSON loads a file that was byte-compiled in an Emacs with native JSON. > We're checking json.c function thrice instead of twice, but doesn't > seem very bad, only a 50% increase :-) Indeed, that wouldn't be an issue. >> But I find this more heavy handed and intrusive, since it >> unconditionally loads json.el during byte-compilation, even when >> json-parse-buffer is available. > > I think the snippet above doesn't have this problem. Indeed, but I think it suffers from the worse aforementioned problem. > Anyway, this is a minor nitpick, push whatever you think is better. Thanks. I've therefore gone with the original patch[1], as it exhibits correct behaviour and is the least intrusive, but you should obviously feel free to tweak it as you prefer. [1]: Various json.el improvements 3f082af536 2020-05-22 15:16:13 +0100 https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3D3f082af536c33ba713= 561e7ad4b691aaad488701 Thanks also to everyone who reviewed the patch. I'm now closing this bug. --=20 Basil