From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id GHjZCSDZCWS5rAAASxT56A (envelope-from ) for ; Thu, 09 Mar 2023 14:03:28 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id uE25CSDZCWTingAA9RJhRA (envelope-from ) for ; Thu, 09 Mar 2023 14:03:28 +0100 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 BB1C59A2A for ; Thu, 9 Mar 2023 14:03:27 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paFup-0000UB-4p; Thu, 09 Mar 2023 08:02:39 -0500 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 1paFun-0000Tz-Vk for emacs-orgmode@gnu.org; Thu, 09 Mar 2023 08:02:38 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1paFul-0005yT-4S for emacs-orgmode@gnu.org; Thu, 09 Mar 2023 08:02:37 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 574A12402F7 for ; Thu, 9 Mar 2023 14:02:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1678366953; bh=Kl7pA++LAbyQGn3AFd6OclDICCL2hvZg2uEuw1JcO04=; h=From:To:Cc:Subject:Date:From; b=G/+mhhYP7gTWsNlsunI6fgbEqRO8DlTAKea6hQm7EsH5Wi62kcPKgjCRNphhU0Kqb 9Cn3OTbhklXYvt+ur5WCjGoIOlk6UMiLofSND8YqQkeBuX55jJhvOb9NAwVy+v6nvv qXt/miQDUb5FpajCTJxSkon+Bx6TEGrIVOE8vUCQKgHRytQGWzRpFYyfX5JbgCXw0t ybmY3R5rkO4dmcwKQiwyNXLDs/I+1eeR724k9kMKNgG2C0gCnk3aXXvPw0HqkeHDv4 LxIAGXEn52CcjbwOgzL/Up6BL1JKf+J43EdGbCDzHrvqrUs6SlmvT7fFluenH7/Jbc Wl5KQerBUvKnQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PXTqX4xQ1z6tmJ; Thu, 9 Mar 2023 14:02:32 +0100 (CET) From: Ihor Radchenko To: Zelphir Kaltstahl , Bastien Cc: Bruno Barbier , emacs-orgmode@gnu.org Subject: [BUG] Inconsistent global/local :var assignments in ob-* for lisps and non-lisps (was: org-babel guile source block bug in handling multiple values) In-Reply-To: References: <9eab60bc-9b82-e037-d63b-3d879573ae32@posteo.de> <87v8jceihi.fsf@localhost> <7fc63848-d6d3-80e0-ae78-00967990813d@posteo.de> <64079614.170a0220.5a0d3.0a23@mx.google.com> <97ee254e-72d2-2bdf-e026-78bde076f1f9@posteo.de> <6408e424.5d0a0220.8862a.2a62@mx.google.com> Date: Thu, 09 Mar 2023 13:04:05 +0000 Message-ID: <87v8jaoz3u.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1678367007; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=549irhCqvS40QkOEx94nZbykRysncmiW+l3lnBOXiDk=; b=WeBKvAHV3GGMhEWKFQN5DwHQpjPVGN0+zSvHFI+vYxQ6k+NoJnMbqs0iHgMJkFP8SjAkhM 3mkp/8fh+tViCr1OzDDFrOXftS43sc1uS41WKj3NPTvJDzdFMlazPgAmfOxUBN/Syljm5M t2r8HrsHZcXTwliLMOMZh1qEVw7b23si/2+RcK8h98MSyoKh9q4pVxyGw4F52xscriGbw/ IakxpLNlt/1+YdzWQM1SgUb6mBKBBxdgUpt6TZ1Qq67HHblrA9HZY4YHIvEKwN6x/pkodH 9wvuSKeb4e9FlQ/T9qMVXrzk+GMh7PbiyDPsWf5DMtMLPr9jnqDKMATpUO1vjw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="G/+mhhYP"; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1678367007; a=rsa-sha256; cv=none; b=MNYWIrYQRcWjkrXVwN5iXp5khe/7JrVlIWtUOcnUXugEbOtEt84eAfFli/P/+NPYXgJW5X wWdExhaUzzkNIxiLnEGpQZoZTZvANpJ6PH7boQBleWJYLRRhfGgvB6dtLgVEebpxFQYrSf vbOH+dutETgWNY2ClS+YNgP1LFMpjbrhEIm141IfFgxo5P7Y7v5oT94BpBXQcb/O9KPjvb COnZjQGKYT1sPzHR9kU4NgvU49TI49za0nuGTTc4mjQ+vJzQL1g334ymL4ldynGFyUTcQG Ady0YUFRk1qlKNnurESSr9n87YnETYtO8kMTU40SDtVIaJ7vKgD3AVYrVJkdLQ== Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="G/+mhhYP"; 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"; dmarc=pass (policy=none) header.from=posteo.net X-Migadu-Spam-Score: -3.19 X-Spam-Score: -3.19 X-Migadu-Queue-Id: BB1C59A2A X-Migadu-Scanner: scn1.migadu.com X-TUID: vfJ8VGlSb9Hr Zelphir Kaltstahl writes: > I am not sure (let ...) is a correct wrapper for noweb included source blocks. > What, if I write a (define ...) in my source block and want to use that source > block via noweb in another source block? Expected behavior I think would be to > be able to access those variables in other source blocks, since they are defined > on a top level in an earlier source block, but if they are wrapped in a (let > ...), that would make them only available in the (let ...)? It seems to me, that > the simple wrapping with a (let ...) might not be the right thing to do. Testing > that: > > ~~~~START~~~~ > #+name: scheme-defs > #+begin_src scheme :eval query-export :noweb strip-export :session myguile :results output replace drawer :var x=1 :var y=2 > (define a x) > (define b y) > #+end_src > > #+name: scheme-time > #+begin_src scheme :eval query-export :noweb strip-export :session myguile :results output replace drawer > <> > (simple-format #t "~a ~a\n" a b) > #+end_src > ~~~~~END~~~~~ > > Indeed, that also does not work. I just checked ob-C, ob-shell, ob-emacs-lisp, and ob-clojure. Non-lisps appear to assign the values globally. In contrast, all the lisp babel backends are using let-bindings. Considering the existing inconsistency, and the raised bug I'd be in favor of making variable assignments global in all the lisp babel backends. The only possible exception is ob-emacs-lisp. Executing elisp code is done in current Elisp session and thus using global variable assignments may be tricky. Unless we juggle with multiple obarrays. > I guess I did never hit this problem earlier, because I "oursourced" my imports > and in imports I do not need any :var header arguments. > > I've asked on the Guile IRC channel and something interesting is the case here > (thanks for clearing it up flatwhatson!) and I understand it as follows: > > Imports inside (let ...) work. It is just that let-values is a macro and macros > are expanded before execution time. However, Guile gets to the body of the > wrapping (let ...) at execution time. That means, that when Guile gets to > evaluate the body of the let, it does not expand the let-values, because it is > already at execution time and no longer at macro expansion time. The import > might import the let-values form, or might not, but it is already too late to > expand the (let-values ...). So, apparently using `let' is not universally safe in Guile. > OK, the question is though, whether org should wrap anything in a (let ...) at > all. During discussion on the Guile IRC, some points against let-wrapping were > brought up: > > (1) The presence of a :var header argument currently determines, whether the > code in the source block is wrapped with a (let ...). One argument for that was, > that this way the variables do not leak. But this also decides, whether other > things leak. For example (import ...) or (define ...). Should :var decide, > whether bindings created with (define ...) are visible in other source blocks > including the source block with the :var header arguments? It seems like a > responsibility :var should not have and definitely is unexpected for the user. This is something Guile-specific. In Elisp, let-binding still allows `defun' or `defvar'. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at