From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: jsonrpc.el uses "Content-Length" headers which seem specific to LSP Date: Thu, 19 Oct 2023 01:11:20 +0100 Message-ID: References: <04f0ef0b-7fcf-4b09-a1c8-94960d8184cf@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="blaine.gmane.org:116.202.254.214"; logging-data="34024"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Adam Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 19 02:09:32 2023 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 1qtGbU-0008gm-7T for ged-emacs-devel@m.gmane-mx.org; Thu, 19 Oct 2023 02:09:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtGae-0006PQ-Gp; Wed, 18 Oct 2023 20:08:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtGac-0006PF-U9 for emacs-devel@gnu.org; Wed, 18 Oct 2023 20:08:38 -0400 Original-Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtGaa-0001Tp-Dy for emacs-devel@gnu.org; Wed, 18 Oct 2023 20:08:38 -0400 Original-Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2c5039d4e88so92213061fa.3 for ; Wed, 18 Oct 2023 17:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697674113; x=1698278913; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hlt0OusJGiqNpyKIhdA+GJQIlH0b9w0CVSRicK76FAI=; b=NqTmwsMFi4BNBU00ivazoq4XgcmKoRPLStZXeeEaFW7vkwcV35gP1wZ8wZyyuHLQjI snGW1/Uz2duih4FKB42+GoPMkiDNfxWTpg63fqZ9b/P0PzV+sQFTjXL+6erMfZIprVIj mCNLIQiBtK74DHvwhftuHqs1vJCk+OW/m2K9Iw4LFzzCS1GnciyLiWuIXRNpildkWKhM YysmJnbtcReBa8xMjG2HSr1A8JH1rdyF1HuRFpGpGHrdQ9a+LUU3XS22YBqFHu0ULDAB D2/pTCq9F2v1CgsjcFB1Pa4xkiVgRqaSMBT8rmmJKrwdG4OGa1k07fTHxteKFDm4t3Dy gaNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697674113; x=1698278913; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hlt0OusJGiqNpyKIhdA+GJQIlH0b9w0CVSRicK76FAI=; b=EsOtf2CWAGSvPeoHwZSyGA2/aA50UKMSbyys6kngyd+XKu0v7vlQUarSkbTFOYwj/C TBoHaSbUQXqK2iZUAO8+fWkSRdX9uulEOnK1uqU6h+ygRzYk7xULsBhpAvfiMmtMQK9N /p7d31DfHf4ROTd+WR4g4n0USggcPHJvOZyNoecM/Ike4Sn/741OezFEhCG0VG4PyIZ5 H2sBWaS6TRE6PQznyrW16JpbWxJlWqiKh9N5m9h2Uqlyy4dWPJmsshk3azBdixVK37O+ 0LOTFn3XJr8wvjHaXX9dtmsVCwXsrIejVMxmfPSZV6y2i4lKPCn0I4i/Vfeqw/X+4lTk RSuw== X-Gm-Message-State: AOJu0YxJFB+Ef7d7sOkbFH0dbk/yxNZQtpnANaAynk0S3Lcq9cmSnXlr 7eJ6yFgCbTsjhtjb/+785iJOQkCuiHAdPFcMLfYCMocg4KtlMQ== X-Google-Smtp-Source: AGHT+IGF+SO1ZPpIr7yy7wlF2vPa5eKq36vGDyo4gtpFUCAlqI1A9XWu8CLNArnYKuUAaxEifpihRsZfDk8cH7VhVWk= X-Received: by 2002:ac2:59cb:0:b0:507:9aec:3014 with SMTP id x11-20020ac259cb000000b005079aec3014mr336669lfn.26.1697674113081; Wed, 18 Oct 2023 17:08:33 -0700 (PDT) In-Reply-To: <04f0ef0b-7fcf-4b09-a1c8-94960d8184cf@alphapapa.net> Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=joaotavora@gmail.com; helo=mail-lj1-x235.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:311565 Archived-At: On Thu, Oct 19, 2023 at 12:17=E2=80=AFAM Adam Porter w= rote: > However, we wonder if jsonrpc.el is not quite as generic as it should > be, i.e. whether the use of these HTTP-style Instead of jsonrpc.el, I think you mean jsonrpc-process-connection. It's a subclass of jsonrpc-connection. If you want more genericity, you could subclass jsonrpc-connection. To give you an example, in a private project I subclassed jsonrpc-connection to make a websocket-based JSONRPC transport. It was really easy (I can show the code if you're interested). Presumably you're interested in using an Emacs pipe or network process as the transport, so by doing that you'd find yourself reinventing lots of stuff in the methods for jsonrpc-process-connection. Let's label this idea= A. Now, the flaw I will concede about jsonrpc-process-connection is that it describes itself as a "jsonrpc connection over an Emacs process", but it would be more accurately described as "JSONRPC connection over HTTP-like over Emacs process". Presumably, you want the first and the last part but not the middle. I guess we could express the existing jsonrpc-process-connection as a mixin of HTTP-like behaviour and Emacs process behaviour. If we did that, you could more elegantly do your own hyperdrive-jsonrpc-connection by mixing in just the classes you wanted. So this is idea B. Back to idea A, we could just bundle most of the functionality used by the generics operating on jsonrpc-process-connection as free helper functions. Then you could just easily build on top of jsonrpc-connection the process-related stuff you want to do and the existing jsonrpc-process-connection would also use these helpers. Nevertheless, I think idea B is cleaner. From reading your email, you seem to agree with me. But I have to see your code first. You seem to have already come up with some kind of idea C. You say the code is "pleasantly simple", yet you still think it could be easier, so I don't know. I haven't seen your pleasantly-simple-but-not-quite-optimal code. I do know subclassing and removing behaviour violates the "is a" of inheritance and sometimes brings you into trouble later on. Or maybe not. So, to summarize, changes to the transport implementor's API in of jsonrpc.el are possible, so long as the current API isn't broken and the new things, be it helpers of idea A or new classes of idea B are documented in the manual. So show me your code and propose some patch to jsonrpc.el showing how much it would simplify your existing code. Jo=C3=A3o