From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eduardo Ochs Newsgroups: gmane.emacs.help Subject: Re: [External] : Re: How do I pass a variable defined in a wrapping let, to a lambda? Date: Sun, 13 Mar 2022 09:19:35 -0300 Message-ID: References: <871qz85bwh.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16223"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 13 13:21:47 2022 Return-path: Envelope-to: geh-help-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 1nTNEI-0003zL-Ab for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 13 Mar 2022 13:21:46 +0100 Original-Received: from localhost ([::1]:39564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTNEG-0007t4-Rw for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 13 Mar 2022 08:21:44 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTNCV-0007sw-1T for help-gnu-emacs@gnu.org; Sun, 13 Mar 2022 08:19:55 -0400 Original-Received: from [2a00:1450:4864:20::22e] (port=43625 helo=mail-lj1-x22e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nTNCT-00031r-6u for help-gnu-emacs@gnu.org; Sun, 13 Mar 2022 08:19:54 -0400 Original-Received: by mail-lj1-x22e.google.com with SMTP id 25so18133477ljv.10 for ; Sun, 13 Mar 2022 05:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FC69H3bu12iZNZ2XTCKmy2Q/0vh9mr4l5+vhSsX6NiU=; b=eXucvTB/kdkxjnlmaEObkKvSWnebZ630UPPyN2YI68wP37GcjJmqG4t3x+Iq6QKBFQ pYP9GLFJoBj4hcExAswxv93m+cviYXaMRtZq2fezTs11Ccuy3X3I6z4nNP2RyK+LPIa1 XirgtNrKZNnXKTuSVO8xZq3bThtUGZEGPbseYrIw5G3T5P1vnvTBz+VNPpzjAKECTAJr ie+xCdXMdq6o9H9sONJuIeswUzRUOY7ng9nsMtPTWcqwzGxzkMKzjUq5lQuZzItWxbxv +8ZB00S4sUeJbZRDHzpCGaKobh95RajWYW5PPYwcYDwukaT9xQTW2YlzLrjkv2MjENdS DBJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FC69H3bu12iZNZ2XTCKmy2Q/0vh9mr4l5+vhSsX6NiU=; b=flqWjttKBjhBAQRKJ8c/3cgltNTG7E3990g0NSYuxDqBNcnTTN5Wp1z+u1amMjYEO7 4l+co9BIJ0uvkckaOtWfCpcM0naRlmI4jvDgNNa9iBMRhpWJ9GKxtkmppZ3BsW9eUQLT Cron+nQ9OwQea5xqN2E0iYcGWHqyiWcuT0t0PTfkQ10n2E7mPEh51uOWjUbw2ri+LS5N nKXK/jklGgf955RtClKukbav0eHAQ8Ka6JauhFerbqBYMd9yBZ9gYtHc3vobuQb7+v5u nFjLW4LVqTQVky6v1yKuXiXYxBD9EtU4MK9n3ieg4uW8kHQg9pezJuLE/zeLCFhHYSt1 5Maw== X-Gm-Message-State: AOAM532In6qOMZLVxjPVCcqXP0Dt7cX+oYfo6Rst6afc0fryPczwTj2d QJNiNzVO7hefQFH/abRrXNomADUrSFuvQhV2/Tss+2kI058= X-Google-Smtp-Source: ABdhPJw18SY4n1i1kU/AaDQyZhXo7t21I788/LsUW8ZENMAUOXKssc1qGt/rAQAOmVAZA0KqNy450spLtdi1yNSjd1g= X-Received: by 2002:a2e:b890:0:b0:249:1c55:741c with SMTP id r16-20020a2eb890000000b002491c55741cmr7850497ljp.193.1647173987204; Sun, 13 Mar 2022 05:19:47 -0700 (PDT) In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::22e (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=eduardoochs@gmail.com; helo=mail-lj1-x22e.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:136513 Archived-At: On Sat, 12 Mar 2022 at 21:08, Stefan Monnier via Users list for the GNU Emacs text editor wrote: > > > Here is something that I don't know how to port to lexical binding. > > My functions that call `ee-template00' are all defined in files with > > "-*- lexical-binding: nil; -*-" - they don't work if I put them in > > files with "-*- lexical-binding: t; -*-". > > You can make it work by sprinkling enough `defvar`, of course: often > add `-*- lexical-binding: t; -*-` is all it takes, but sometimes you > have to work harder. > > I remember battling with this code to beat it into submission by > restructuring it a bit so that it doesn't rely so heavily on > `eval` and dynamic scoping. I must have sent you the resulting patch back > then (that was around the time we added it to GNU ELPA). > > > > ;; (let ((hi "Here: ") (a 22) (b 33)) (ee-template00 "{hi}{a}+{b}={(+ a b)}")) > > Try > > (dlet ((hi "Here: ") (a 22) (b 33)) (ee-template00 "{hi}{a}+{b}={(+ a b)}")) > > or > > (defvar hi) (defvar a) (defvar b) > (let ((hi "Here: ") (a 22) (b 33)) (ee-template00 "{hi}{a}+{b}={(+ a b)}")) > > IIRC my patch changed `ee-template00` into a macro, instead, so the references > inside your string template had lexical access to the variables. Ouch, Stefan, sorry - when you sent me that code I misread something and I thought that it was just an incomplete prototype... it was not, only its docs were incomplete. I have just added it to eev with very small changes - now people can choose between `ee-template0', that needs dynamic binding but is easier to understand, and `ee-template0-lex', that works in both dynamic binding and lexical binding but uses macros... The code is here: http://angg.twu.net/eev-current/eev-template0.el.html#ee-template0-lex Cheers =S, E.