From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxime Devos Newsgroups: gmane.lisp.guile.devel Subject: RE: Define works different when Compile and Eval Date: Sat, 22 Jun 2024 18:45:54 +0200 Message-ID: <20240622184554.eglt2C00J59JEwj01gltV5@xavier.telenet-ops.be> References: <875xu5i9qr.fsf@trop.in> <87r0cq8ogp.fsf@trop.in> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_E34D4823-2A92-4AAF-B413-0821B3282040_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6179"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "guile-devel@gnu.org" To: Attila Lendvai , Andrew Tropin Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sat Jun 22 18:46:26 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 1sL3sf-0001NF-2E for guile-devel@m.gmane-mx.org; Sat, 22 Jun 2024 18:46:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sL3sP-0002Ya-8H; Sat, 22 Jun 2024 12:46:09 -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 1sL3sM-0002Xa-MA for guile-devel@gnu.org; Sat, 22 Jun 2024 12:46:06 -0400 Original-Received: from xavier.telenet-ops.be ([2a02:1800:120:4::f00:14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sL3sH-00088A-EJ for guile-devel@gnu.org; Sat, 22 Jun 2024 12:46:06 -0400 Original-Received: from [IPv6:2a02:1811:8c0e:ef00:c29:b9fe:857f:91eb] ([IPv6:2a02:1811:8c0e:ef00:c29:b9fe:857f:91eb]) by xavier.telenet-ops.be with bizsmtp id eglt2C00J59JEwj01gltV5; Sat, 22 Jun 2024 18:45:54 +0200 Importance: normal X-Priority: 3 In-Reply-To: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=telenet.be; s=r24; t=1719074754; bh=B5YHbfuBo4dU7A9VKvoLSSLeuuvzH6BFgCZatYClzwY=; h=To:Cc:From:Subject:Date:In-Reply-To:References; b=fYfwy6oQMxw54JSkyGIUVt++hnLWVrxKZvjtLj65UtKzkaHMAXhdsGitiBXWIBcKx yLj5Z6Vs/HH63TpNW/1gtWczY4Eg4zzG2ibDP6rAlugrd4ZNAueFSwjL8MieZG7ptS 2jsPC00mpRVrX/7BgVFe4GIkTNamzIwQT8to9FCVttUY8cB0ZL7mY6oke6XYHgmPyC PxhIuNzQ9cbvUr8iz1MAzEq1wSfQYzFkSZ/kvmGv8WJawMt/cBvL4yODvlL5XhW+Tf +rrJAffnbTtV5Eq0AikFYgVGPNHjKR3/Z98kKBUdmtJKdrW9PQgei2PWbL2pTxY8bI newkYx3p331Qw== Received-SPF: pass client-ip=2a02:1800:120:4::f00:14; envelope-from=maximedevos@telenet.be; helo=xavier.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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:22461 Archived-At: --_E34D4823-2A92-4AAF-B413-0821B3282040_ Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" > > > if you want this^ to be actually defined while compilation is > > > happening (i.e. in the compilation stage; see staged computing), then > > > you need to use an (eval-when (expand) ...) wrapper around it. >=20 >=20 > > Thank you for the reply! Not sure what you mean. The following code > > defines `a`: >i ran with some ungrounded assumptions, and i basically explained how it w= orks in CL, not in Guile. It works like that in (Guile) Scheme too. Though, to be precise, =E2=80=98e= xpand=E2=80=99 refers to the macro expansion phase, whether compiling or no= t. =E2=80=98compile=E2=80=99 is for =E2=80=9Cevaluate during macro expansio= n, but not only when compiling=E2=80=9D. >[...] >i briefly tired to find the place where DEFINE is compiled to check this h= ypothesis in the code, but i couldn't find it. In macro-expansion: =E2=80=A2 https://git.savannah.gnu.org/cgit/guile.git/tree/module/ice-9/psy= ntax.scm#n1370 (also see mentions of =E2=80=98define-form=E2=80=99) Evaluation: =E2=80=A2 Probably somewhere in https://git.savannah.gnu.org/cgit/guile.git= /tree/module/ice-9/eval.scm =E2=80=A2 Perhaps somewhere in https://git.savannah.gnu.org/cgit/guile.git/= tree/libguile/eval.c as well In Tree-IL: * https://git.savannah.gnu.org/cgit/guile.git/tree/module/language/tree-il.= scm#n220 * https://git.savannah.gnu.org/cgit/guile.git/tree/module/language/tree-il.= scm#n310 Also maybe see relevant optimisation code and other layers of the compilati= on tower. --_E34D4823-2A92-4AAF-B413-0821B3282040_ Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"

> > > if you want this^ to be actually defined while= compilation is

> > > happening (i.e. in the compilation stage; see staged compu= ting), then

&g= t; > > you need to use an (eval-when (expand) ...) wrapper around it.=

>

>

> > Thank you for the r= eply! Not sure what you mean. The following code

> > defines `a`:=

>i ran with some ungrounded = assumptions, and i basically explained how it works in CL, not in Guile.

 

It works like that in (= Guile) Scheme too. Though, to be precise, =E2=80=98expand=E2=80=99 refers t= o the macro expansion phase, whether compiling or not. =E2=80=98compile=E2= =80=99 is for =E2=80=9Cevaluate during macro expansion, but not only when c= ompiling=E2=80=9D.

 

&g= t;[...]

>i = briefly tired to find the place where DEFINE is compiled to check this hypo= thesis in the code, but i couldn't find it.

 

In macro-expansion:

 

Evaluation:

 

= In Tree-IL:

* https://git.savannah.gnu.org/cgit/gui= le.git/tree/module/language/tree-il.scm#n220

* https://git.savanna= h.gnu.org/cgit/guile.git/tree/module/language/tree-il.scm#n310

 

Also maybe see relevant optim= isation code and other layers of the compilation tower.

= --_E34D4823-2A92-4AAF-B413-0821B3282040_--