From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Taylan Kammer Newsgroups: gmane.lisp.guile.devel Subject: Re: Lexically bound macro, with lexically bound transformer Date: Wed, 24 Jul 2024 13:15:38 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19498"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird To: spacecadet , guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed Jul 24 13:16:17 2024 Return-path: Envelope-to: guile-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 1sWZyj-0004vJ-MT for guile-devel@m.gmane-mx.org; Wed, 24 Jul 2024 13:16:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWZyH-0001GD-9A; Wed, 24 Jul 2024 07:15:49 -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 1sWZyF-0001AE-JH for guile-devel@gnu.org; Wed, 24 Jul 2024 07:15:47 -0400 Original-Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWZyC-0003rY-CI for guile-devel@gnu.org; Wed, 24 Jul 2024 07:15:47 -0400 Original-Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a7a8553db90so221375366b.2 for ; Wed, 24 Jul 2024 04:15:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721819742; x=1722424542; darn=gnu.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=P1byG382GgavXxtBy+Wseu2AL3r2LfDrFwti5XgWyZY=; b=m2pcwg3Gh4BUStDWn6Ax4oVRgJ/0F/ZIS1c5tw4XkguzS5enTg0nEVv0t9ropghycm bsY2R6ewPIKG4nPCPnn3jsbrzT7EhKsPEcqi5Iy1RX+pzpqeNlGvOJNi2JWy7gNT3SwD rsGZsUMMV7tIjoz5gGFSOLdPcJuoAySaQ00ZFlviE/abqU+oqNJkVY8b+dBHYb6zDiy9 2/ES7t5dhzKS4OewkN/CnDZjCz6qjLedPiIz95G/z8jmMxJHQNKhgbahsZzpcIvNhbmO a9DQqqr+BrjsbyzqzPI3BW3WocEEaaud8AJJRqczyVUJxxRKTchkBtvpBQk148qTYC1z AOgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721819742; x=1722424542; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P1byG382GgavXxtBy+Wseu2AL3r2LfDrFwti5XgWyZY=; b=HVwNUgiHV1Ch3JJDCJKbOuCBDZiqqb3JPWB0WKjcrxL+lBEeuZsfVLF8IF9re+q4hm xqDOhJseFbdU99hlH/SdhNVr5ur9KGTvQhKcOJOtAdWb7OgSjniQZ6j9m3j4wL4VMVNL s2Nflv0GuMOAwHUf4uksDXKkj1VEdmLvgGrc9M2qO539UkYB+afpFjooj415qK2SXf16 lMRB4se0WtQGJY9C6+QNSC+Mv+fCVnIVjWFvwiE5p/bj6SEEDE01o8wjWxIHzGnUWW8f DnfjsDGfrbbQlfFCiRDWZgpyH/VU7QFoOS2MVF9nVFyxmRIjtETyQdtx0skPpm5rPOES F3cw== X-Forwarded-Encrypted: i=1; AJvYcCWtDwJ4bzp+U9Q+lbloqKA8fH3hMj7mo6jvX8kdI2a+qwaiwb5u7SoBVPJNZMNl4qEtGD/LthqI9iL7+vOD4ESJYVhZ X-Gm-Message-State: AOJu0Yx833cvJETLK2/up9JtR1voEs0MuWhAHAMNGONCk3Ccp7cmbQOo TMDPIGhYMqNUzc0LCN4b3Vl1IInCiP7ndsuwlSWyamgRkaUOyXyo X-Google-Smtp-Source: AGHT+IGru2BecBUVpBZEX5921profLwgXwXmuWnepTt4kkUHdYcN8sWMKxQdMNzr7CVvXOJk4C1fkw== X-Received: by 2002:a17:906:6a19:b0:a77:e48d:bae with SMTP id a640c23a62f3a-a7ab0ede632mr122950866b.28.1721819741679; Wed, 24 Jul 2024 04:15:41 -0700 (PDT) Original-Received: from ?IPV6:2003:106:8f00:2c00:bc0c:7e5b:4fcd:a1c3? (p200301068f002c00bc0c7e5b4fcda1c3.dip0.t-ipconnect.de. [2003:106:8f00:2c00:bc0c:7e5b:4fcd:a1c3]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7abfa067ecsm1356266b.176.2024.07.24.04.15.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Jul 2024 04:15:41 -0700 (PDT) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=taylan.kammer@gmail.com; helo=mail-ej1-x62e.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: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22655 Archived-At: On 24.07.2024 03:06, spacecadet wrote: > Hi, I didn't see a help-guile list, I hope this isn't out of place I think the guile-user list might be more appropriate. > I'm trying to lexically bind a macro to a lexically bound transformer procedure > > (let ((outer (lambda (x) #''()))) >   (let-syntax ((inner outer)) >     inner)) > > This is producing an error > "reference to identifier outside its scope in form outer" > > My goal is to load external macros without any top-level definitions > I don't know if the way the macro expander works will allow this > Any help appreciated, thanks! Scheme evaluation could be considered to happen in two parts, regardless of whether the implementation actually has a compiler: 1. The compile-time execution of code 2. The run-time execution of code (Guile actually has a compiler so it's definitely like this in practice too.) The 'let' form works in the context of run-time execution, whereas 'let-syntax' works in compile-time execution. Although compile-time code can "see" that a variable called 'outer' is bound in the lexical scope, the actual value of the binding will only exist at run-time, so you can't rely on it during compile-time execution. The following works: (let-syntax ((outer (lambda (x) #'(+ 1 2)))) (let-syntax ((inner (lambda (x) (outer x)))) (inner))) The 'inner' has to be a lambda too, and can't be bound to 'outer' directly. I'm not sure why. -- Taylan