From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Platon Pronko Newsgroups: gmane.emacs.help Subject: Re: the (declare special) declaration with lexical scope. Date: Sun, 23 Apr 2023 17:47:40 +0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21671"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 To: Madhu , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 23 11:48:14 2023 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 1pqWKM-0005Xh-3p for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 23 Apr 2023 11:48:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqWJy-00062u-WF; Sun, 23 Apr 2023 05:47:51 -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 1pqWJx-00062L-6q for help-gnu-emacs@gnu.org; Sun, 23 Apr 2023 05:47:49 -0400 Original-Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pqWJv-0006VQ-OW for help-gnu-emacs@gnu.org; Sun, 23 Apr 2023 05:47:48 -0400 Original-Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2472740a0dbso3116100a91.3 for ; Sun, 23 Apr 2023 02:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682243265; x=1684835265; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=n1i+dB3qYiVTQX4jrvTijuia+96GO0g2gW0KG68hcsI=; b=Ao7PXXNq5yNrnOdB847GGiYD3ap+pktWCmZXT+6HhFfW+Rc8TqM9IU6jkQkSQt0FjO 529hb6xfW5mVbrapkx8oyIjCYzJKK3V1ZsDQZhyuv6TClzUZ8zVAhca7pk42Q2oea+cj +0STooP9lsIcOcR1cJLC8FZK9LH6StBoqZGmDjvCeewUmTaDAmnFTOvrety2TF3gLkHC 7V6KwebriBx/FuSfgjFChkzNVgLWp+y4nqkJD/i3mFW14ONraStgLBhQd+++WaZBd0UA SzOgVS71WPqCtMo1uoWJ5+zG/F3I5BhiCMxmIGIvoOzke0RMnJGgAQ9p8k0b+knzsgEx vuTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682243265; x=1684835265; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=n1i+dB3qYiVTQX4jrvTijuia+96GO0g2gW0KG68hcsI=; b=V5zFXeUDP48KRptphfx96HRZR7ARo/txOGf871tyPgUJZf2vlRccScktwf3kAA/Xrm bs4BQWnKyi0fXRYw6XkEp0vonytSS0eM/dN2MKAfuz+Q1cUvuNBoaJsqIXQopkvEjntZ 3RY+B1GRyrDQ4JR43omXuY0LfFja8+T2ZFs2VrlX50X0efq6dKASzC4Uw5RRoipGwTWO /LL7d+p0pftrqX8/p4YvD3ev9RZTt1kVo8UwGQOY7ZHuF6kxMcxAtS34zl+70QK/ytOU bx+BHyMaHG2vrLZxBQHYOmqsTqFhDr6Jf9qoFlYrP/31bmyP5gpdCPSfYKus0f0SMn7W WEhA== X-Gm-Message-State: AAQBX9eXIT3ofUxjsj5O8UDIdkkoUuFnPWsWxyP7LA6pSMm2piMls9Gf 1ENqq/NU7LfDGFubHIIz6OwJZjdMzUr8iQ== X-Google-Smtp-Source: AKy350ZVDNqSELbfPXIAxB8yLy7ARlSQvYBb3sT0SqtK0AJEku51IneRQV0XC3POUs0DNaaKOhaTdQ== X-Received: by 2002:a17:90a:6948:b0:249:8963:c72 with SMTP id j8-20020a17090a694800b0024989630c72mr10415567pjm.17.1682243265273; Sun, 23 Apr 2023 02:47:45 -0700 (PDT) Original-Received: from [192.170.1.133] ([103.24.106.35]) by smtp.gmail.com with ESMTPSA id h11-20020a170902748b00b001a641e4738asm4931254pll.1.2023.04.23.02.47.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 23 Apr 2023 02:47:44 -0700 (PDT) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=platon7pronko@gmail.com; helo=mail-pj1-x1036.google.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 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, NICE_REPLY_A=-2.047, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143340 Archived-At: I'm not qualified to answer the question about lexical scope. However I'm interested why you didn't consider to make the entire mustache function into a macro that expands to concat call with variables already interpolated? This way it will work regardless of lexical or dynamic binding. I suppose this might break if template is dynamically generated somewhere, however templates are usually static and thus can be embedded at compile time (it will be the fastest-performing option, aside from other benefits). Here's an example of what I mean: (defun mustache-build (template) (let ((pattern-start (string-match "{{\\(.*?\\)}}" template))) (if (not pattern-start) template `(,(substring template 0 pattern-start) (prin1-to-string ,(intern (match-string 1 template))) ,@(if (>= (match-end 0) (length template)) nil (mustache-build (substring template (match-end 0)))))))) (defmacro mustache (template) `(concat ,@(mustache-build template))) (macroexpand '(mustache "a={{a}} b={{b}}")) ; (concat "a=" (prin1-to-string a) " b=" (prin1-to-string b)) (let ((a 42) (b '(+ 2 3))) (mustache "a={{a}} b={{b}}")) ; "a=42 b=(+ 2 3)" -- Best regards, Platon Pronko PGP 2A62D77A7A2CB94E