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: [BUG] Eval sets incorrect runtime metainformation Date: Sun, 30 Jun 2024 01:05:22 +0200 Message-ID: <20240630010523.hb5N2C00D3x6CSs01b5P7x@xavier.telenet-ops.be> References: <87bk3pkqmt.fsf@trop.in> <87msn86ops.fsf@igalia.com> <20240626113611.g9cB2C0023K6y2F069cBEe@michel.telenet-ops.be> <87tthgj5hi.fsf@trop.in> <36db048b-2465-4088-b46c-b20e24cd0b66@philipmcgrath.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_1F898A2B-1BE6-430E-B82F-8FB653C0195E_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1753"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "guile-devel@gnu.org" To: Philip McGrath , Andrew Tropin , Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Jun 30 01:05:46 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 1sNh8c-0000Bj-7j for guile-devel@m.gmane-mx.org; Sun, 30 Jun 2024 01:05:46 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNh8Q-0006ij-1O; Sat, 29 Jun 2024 19:05:34 -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 1sNh8O-0006iJ-3R for guile-devel@gnu.org; Sat, 29 Jun 2024 19:05:32 -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 1sNh8L-0006Lf-9d for guile-devel@gnu.org; Sat, 29 Jun 2024 19:05:31 -0400 Original-Received: from [IPv6:2a02:1811:8c0e:ef00:d922:a19:7580:f08e] ([IPv6:2a02:1811:8c0e:ef00:d922:a19:7580:f08e]) by xavier.telenet-ops.be with bizsmtp id hb5N2C00D3x6CSs01b5P7x; Sun, 30 Jun 2024 01:05:23 +0200 Importance: normal X-Priority: 3 In-Reply-To: <36db048b-2465-4088-b46c-b20e24cd0b66@philipmcgrath.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=telenet.be; s=r24; t=1719702323; bh=qPSXtN980qksv6TrJEORpxcLQ0ShU/FWkm1g9SnFgu0=; h=To:Cc:From:Subject:Date:In-Reply-To:References; b=cofoa4KKjbDZSUXZuzPAdVL/sMZs0mWJXzPpAQuMowBz0Y/QUysVypCOLqt5lSs4t I31NpWjgP8dzE9mOJI7oPCqey0Ku5Rr6E5Qy2pvl9mk9guW9eE6ie0V0oumenaFukm p4+C1IIU6sACho8R7uraGz4fJ+bvv+FTz2BjS4SMwu4b57EHsbuATRadFY2Yn5FSKk GFzsfq3My2bsCcetprs+V9Wk2Bvr2gThdmsDJtddl+gkiDoMjT2VKsDghCFYJtSJBT wZDwfhEZU4cNVobIlexRScq/0WIu3NCvjDX4bGjSYJ4X5a2gzrdSIuh2oq3t02XJaM fH+dOpNgZxTDQ== 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:22514 Archived-At: --_1F898A2B-1BE6-430E-B82F-8FB653C0195E_ Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" >Instead of run-time reflection on values, I think an IDE implementing=20 jump to definition should use source location and binding information=20 from syntax objects. That's how DrRacket does it. >The attached DrRacket screenshot (of [1]), in which I've tacked a bunch=20 of binding arrows, shows how local definitions and complex=20 macro-introduced binding structures are supported. It also works across=20 modules, even with renaming: in the program `#lang racket (define one=20 1)`, right-clicking on `define` and choosing "Jump to Binding=20 Occurrence" will highlight `racket`, because the initial import of the=20 racket language establishes the applicable binding of define, whereas=20 choosing "Open Defining File" will open the racket/private/kw module,=20 and then choosing "Jump to Definition (in Other File)" will jump to the=20 definition of `new-define` on line 1171 of kw.rkt, which is renamed=20 elsewhere to become the `define` of `#lang racket`. >Since syntax objects from the expander encode all the details of scope,=20 this works mostly automatically. DrRacket makes this functionality=20 available as a library, so navigation features can also be used from=20 Emacs with racket-xp-mode [2] or other editors with the Language Server=20 Protocol [3]. I suppose this could work, but it seems the wrong layer of abstraction and = a bit round-about to me, it also only works on languages that use Scheme-st= yle syntax. Instead, I=E2=80=99d propose compiling the relevant code to Tre= e-IL (without optimisations, should work with most languages). (For Scheme= , this is essentially macro expansion, but the resulting object won=E2=80= =99t technically be a syntax object.) In Tree-IL, all syntax has been expanded (in tree form), which eliminates a= lot of complications. Yet, source location information remains available (= albeit not documented ...)! And the original variable names remain availabl= e (together with an unshadow-ified version, so for local variables you can = move upwards to find the corresponding definition and in particular its sou= rce location. A large upside is that this should work for most languages (not only Scheme= ) and is relatively straightforward to implement, a small downside is that = information on definitions like (let-syntax ((f [...])) ...) aren=E2=80=99t= available =E2=80=93 you only see the return of (f stuff), not =E2=80=98f= =E2=80=99 itself. (But this downside applies to the =E2=80=98syntax=E2=80=99 route as well, u= nless you are doing complicated (but possible!) DIY partial macro expansion= shenanigans.) Best regards, Maxime Devos. --_1F898A2B-1BE6-430E-B82F-8FB653C0195E_ Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"

>I= nstead of run-time reflection on values, I think an IDE implementing

jump to definition should use source location and bindin= g information

from syntax objects. That's how DrRa= cket does it.

 

>The attached DrRacket screenshot (of [1]), in which I've tacked a = bunch

of binding arrows, shows how local definitio= ns and complex

macro-introduced binding structures= are supported. It also works across

modules, even= with renaming: in the program `#lang racket (define one

1)`, right-clicking on `define` and choosing "Jump to Binding <= /p>

Occurrence" will highlight `racket`, because t= he initial import of the

racket language establish= es the applicable binding of define, whereas

choos= ing "Open Defining File" will open the racket/private/kw module, =

and then choosing "Jump to Definition (in Oth= er File)" will jump to the

definition of `new= -define` on line 1171 of kw.rkt, which is renamed

= elsewhere to become the `define` of `#lang racket`.

 

>Since syntax objects from th= e expander encode all the details of scope,

this w= orks mostly automatically. DrRacket makes this functionality

available as a library, so navigation features can also be use= d from

Emacs with racket-xp-mode [2] or other edit= ors with the Language Server

Protocol [3].

 

I suppose this c= ould work, but it seems the wrong layer of abstraction and a bit round-abou= t to me, it also only works on languages that use Scheme-style syntax. Inst= ead, I=E2=80=99d propose compiling the relevant code to Tree-IL (without op= timisations, should work with most languages).=C2=A0 (For Scheme, this is e= ssentially macro expansion, but the resulting object won=E2=80=99t technica= lly be a syntax object.)

 

In Tree-IL, all syntax has been expanded (in tree form), wh= ich eliminates a lot of complications. Yet, source location information rem= ains available (albeit not documented ...)! And the original variable names= remain available (together with an unshadow-ified version, so for local va= riables you can move upwards to find the corresponding definition and in pa= rticular its source location.

 

=

A large upside is that this should work for most langu= ages (not only Scheme) and is relatively straightforward to implement, a sm= all downside is that information on definitions like (let-syntax ((f [...])= ) ...) aren=E2=80=99t available =E2=80=93 you only see the return of (f stu= ff), not =E2=80=98f=E2=80=99 itself.

 

(But this downside applies to the =E2=80=98synt= ax=E2=80=99 route as well, unless you are doing complicated (but possible!)= DIY partial macro expansion shenanigans.)

&nb= sp;

Best regards,

Max= ime Devos.

= --_1F898A2B-1BE6-430E-B82F-8FB653C0195E_--