From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id QIRcG1YUtWID4QAAbAwnHQ (envelope-from ) for ; Fri, 24 Jun 2022 03:33:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id mLJEG1YUtWKVFAEAauVa8A (envelope-from ) for ; Fri, 24 Jun 2022 03:33:10 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8A0A611308 for ; Fri, 24 Jun 2022 03:33:09 +0200 (CEST) Received: from localhost ([::1]:39512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4YC4-0005Pc-6f for larch@yhetil.org; Thu, 23 Jun 2022 21:33:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4YAe-0005N7-Dr for emacs-orgmode@gnu.org; Thu, 23 Jun 2022 21:31:41 -0400 Received: from mail-40140.protonmail.ch ([185.70.40.140]:42122) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4YAb-0007kl-QS for emacs-orgmode@gnu.org; Thu, 23 Jun 2022 21:31:39 -0400 Date: Fri, 24 Jun 2022 01:31:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1656034293; x=1656293493; bh=q4MbwKPMutphQo5jueIfiCM5BPjBrXOxtGkstljCa6w=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:Feedback-ID:From:To:Cc:Date:Subject:Reply-To: Feedback-ID:Message-ID; b=IHHpgwFb9gJy83izpvqPTQm8zIrN4d+NGw3dCWaN5Mlj7Pkkx0XeaCr8VItC1pv+K zTedpy4YcIQHMIxEicMIRVUSmgT3ILNWrXmx+sE+w8FuOyXJ3mGDBjXF9uvFRpUm+a NzPSPF7B1ueI8XpLmj0o2AOg/wir0ctmRjVmtPjMrho5GqKtK3ZjHTgNkIglMAWSMh 7jSzZUNqT7aM3wYzljPasTInwDd75gUTgQSD9UApffUEwyv+8WCh8mew3cLHs0T9XU ak9QyIEoqV4ccEGg6Bg0AoQzHPARFsl4DqbwOO076vwq+d8mk7LEe34APdFFWTEeUz Y1CthaMLJwEIg== To: Tim Cross From: Ivar Fredholm Cc: emacs-orgmode@gnu.org Subject: Re: Using exec functions to simplify session code Message-ID: <4GgreROUkMant3E8LK7kKgeciZbHZDaEywwaKsZk34klCmvBr9paFe9ay4YziC80ubNd7mqwbbETwbjv6Q9EIs_3M1mM_Mv3H9cHOOyVr1I=@protonmail.com> In-Reply-To: <87tu8a7txl.fsf@gmail.com> References: <1vlD0t1ffNxmDCckK6W2md-OzxdCEmzV4IIF9Yop-sNhQgF1lg5bgmaTAO4YcS66JoHyTEBUzJiaY4n8g5l_lxWFiaQ4u_a-CKlvMAoOKCM=@protonmail.com> <87tu8a7txl.fsf@gmail.com> Feedback-ID: 16540637:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.40.140; envelope-from=freddyholms@protonmail.com; helo=mail-40140.protonmail.ch 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Ivar Fredholm Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1656034389; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=q4MbwKPMutphQo5jueIfiCM5BPjBrXOxtGkstljCa6w=; b=gitCMu22zesHUhrotvZQbMcjIScxGT3j3HO8huvNbLSg5z67FMvY7okN3pFCJjJyzk85qj EpJesMYPUteR8PSY02uUleefV/uiOb33jnuZ5AuJFia1RhDHoqRVrpN7aksjrfpB8I5dAT EjfqApzjFc3dA0Oe3qghzjdbiKkB3xlQg5OgkrbHrIzRVct0gktrd0kIvKm1T3YdLfWRTd h0vEije1bBfi0tAylZPFGweOeyM/UjZHyiiiMjvCdoB1X2+bioeCggIlDfYf2DHu0YWUed OSe4QuqZG/xHc2LuY32T2Y+XJgS8z49Sx2U/n+ENqKSkUlPLD7IjhzpeEUEwHQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1656034389; a=rsa-sha256; cv=none; b=Vgf2MyN5R/wjVwZBZqscG/Eac60Ba3w93YWX6mO4pjdLqbFE71hcdkJ7nG9qt3I23wThCG rEgk4zP53ty1JtMvKgnfzWcLGL4V0y2irbGEb98sRysevkiQMNdomF3go6Apb4n+DdVf84 PnhpznXISqAYU2z/CdOkBSqLeuiu7iz8PWAByZth6mxWCyAOcZorSvcVZER8Mx1jndzJQI eNLNG2RbX2Tj8ZhXdwy628QDltnH4uylDJ2JQGIF7jIRU5zS6jfuFETPsPj7Wl5/DYzVW8 GNZhGoFL4xcdNPnf5OUbLXgr/f5rjJLiZn57p/4r+ushzDgaJRwTduTJeGaY8g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=protonmail.com header.s=protonmail3 header.b=IHHpgwFb; dmarc=pass (policy=quarantine) header.from=protonmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -5.46 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=protonmail.com header.s=protonmail3 header.b=IHHpgwFb; dmarc=pass (policy=quarantine) header.from=protonmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 8A0A611308 X-Spam-Score: -5.46 X-Migadu-Scanner: scn0.migadu.com X-TUID: am7wTY23pM2O Hi, Tim, Let's say in your example that we are executing Python cells with the same = session. When you execute block 1, the routines in org-babel-execute-src-bl= ock process the code into something that can be inserted into a file (say '= tmp_code.py') and be run from the command line with python3 tmp_code.py. At this point, Babel calls org-babel-execute:python, which decides, based o= n the 'session' header, whether or not to call python3 tmp_code.py or to fe= ed each line in tmp_code.py into the session interpreter. What I am wonderi= ng is if we could replace the code for the latter option (in ob-comint.el) = by just sending the interpreter the command 'exec(open("tmp_code.py").read(= ))'. Now you can still run block 2 or 3, or block 2 twice, or neither. I think t= his would simplify a lot of the comint code. All we would need to do is cha= nge how we implement the 'exec(open...' code in other languages, for instan= ce, I believe in julia this could be done by an 'include'. Best, Guacho Sent with Proton Mail secure email. ------- Original Message ------- On Thursday, June 23rd, 2022 at 7:53 PM, Tim Cross = wrote: > Ivar Fredholm freddyholms@protonmail.com writes: > > > I have been browsing the orgmode code and it feels like we have to do a= lot to implement sessions. At least for Python > > or Julia, I am wondering if we could instantiate an interpreter, and se= nd the code as a single 'exec' or 'include' > > command. Other languages like R and groovy also have facilities to run = code from a file. I believe this would reduce the > > amount of code needing maintenance, as we would only need to manipulate= the string to pass to the interpreter based > > on the language. If this has been considered before, could someone expl= ain why this approach was not used? > > Best, Guacho > > > I agree that supporting session can be complex, especially with some > languages. The big limitation I can see with your suggestion (assuming I > understand what your proposing) is that you may not necessarily want to > execute all the blocks at once or only execute a block once. > > For example, I might have an org file with 4 code blocks which I want to > all run in the same session. However, I might want to execute each block > interactively, not run all four blocks sequentially all in one batch. I > might execute block 1, then based on the result/output form that block, > execute block 2 or 3, but maybe not both or perhaps I will execute block > 2 twice before executing block 3 etc. > > If you adopt your approach, we would loose that flexibility. The session > argument would essentially boil down to execute all code blocks in this > file within the same batch rather than execute each one in a separate > environment/instance. While this could be a valid interpretation of > session, we would need to be sure it was one which all users found > agreeable. It is possible, for stability and maintainability, a new > definition of session would be acceptable, but it is a change with > implications that would need to be managed carefully.