From: Philip McGrath <philip@philipmcgrath.com>
To: Maxime Devos <maximedevos@telenet.be>,
Andrew Tropin <andrew@trop.in>, Andy Wingo <wingo@pobox.com>
Cc: "guile-devel@gnu.org" <guile-devel@gnu.org>
Subject: Re: [BUG] Eval sets incorrect runtime metainformation
Date: Sun, 30 Jun 2024 18:27:09 -0400 [thread overview]
Message-ID: <718e88a7-36b8-4e72-84b6-5156f7d75896@philipmcgrath.com> (raw)
In-Reply-To: <20240630010523.hb5N2C00D3x6CSs01b5P7x@xavier.telenet-ops.be>
On 6/29/24 19:05, Maxime Devos wrote:
> > Instead of run-time reflection on values, I think an IDE implementing
> > jump to definition should use source location and binding information
> > from syntax objects. That's how DrRacket does it.
> > ...
> > Since syntax objects from the expander encode all the details of scope,
> > this works mostly automatically. DrRacket makes this functionality
> > available as a library, so navigation features can also be used from
> > Emacs with racket-xp-mode [2] or other editors with the Language Server
> > 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-style syntax. Instead, I’d propose compiling the relevant code to
> Tree-IL (without optimisations, should work with most languages). (For
> Scheme, this is essentially macro expansion, but the resulting object
> won’t 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 available (together with an unshadow-ified version, so for
> local variables you can move upwards to find the corresponding
> definition and in particular its source location.
>
> A large upside is that this should work for most languages (not only
> Scheme) and is relatively straightforward to implement,
I hadn't realized that other languages in Guile might compile to Tree-IL
directly instead of generating syntax objects. Is that common and/or
encouraged? It seems like it would require the new language's compiler
to do a lot of work that could otherwise be delegated to Guile, and it
would make it difficult to implement parts of the new language using macros.
> a small downside
> is that information on definitions like (let-syntax ((f [...])) ...)
> aren’t available – you only see the return of (f stuff), not ‘f’ itself.
>
> (But this downside applies to the ‘syntax’ route as well, unless you are
> doing complicated (but possible!) DIY partial macro expansion shenanigans.)
>
This and other features, like correctly tracking the binding of `else`
in `cond`, require cooperation from the macro expander. The explanation
of origin tracking in
<https://docs.racket-lang.org/reference/stxprops.html> might be one
place to start reading about how Racket supports this (but I am not an
expert!). Similar expander features can also enable other tools, like
DrRacket's macro stepper:
<https://docs.racket-lang.org/macro-debugger/index.html>
Philip
next prev parent reply other threads:[~2024-06-30 22:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 15:07 [BUG] Eval sets incorrect runtime metainformation Andrew Tropin
2024-06-26 9:24 ` Andy Wingo
2024-06-26 9:36 ` Maxime Devos
2024-06-26 11:41 ` Andrew Tropin
2024-06-26 22:06 ` Philip McGrath
2024-06-28 13:20 ` Andrew Tropin
2024-06-29 19:55 ` Philip McGrath
2024-06-29 23:05 ` Maxime Devos
2024-06-30 22:27 ` Philip McGrath [this message]
2024-07-01 9:06 ` Maxime Devos
2024-07-06 16:42 ` Rob Browning
2024-07-06 18:56 ` Matt Wette
2024-06-26 16:04 ` Andy Wingo
2024-06-28 13:27 ` Andrew Tropin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=718e88a7-36b8-4e72-84b6-5156f7d75896@philipmcgrath.com \
--to=philip@philipmcgrath.com \
--cc=andrew@trop.in \
--cc=guile-devel@gnu.org \
--cc=maximedevos@telenet.be \
--cc=wingo@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).