unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Philip McGrath <philip@philipmcgrath.com>
To: Andrew Tropin <andrew@trop.in>, Andy Wingo <wingo@pobox.com>
Cc: Maxime Devos <maximedevos@telenet.be>,
	"guile-devel@gnu.org" <guile-devel@gnu.org>
Subject: Re: [BUG] Eval sets incorrect runtime metainformation
Date: Wed, 26 Jun 2024 18:06:50 -0400	[thread overview]
Message-ID: <36db048b-2465-4088-b46c-b20e24cd0b66@philipmcgrath.com> (raw)
In-Reply-To: <87tthgj5hi.fsf@trop.in>

[-- Attachment #1: Type: text/plain, Size: 2827 bytes --]

On 6/26/24 07:41, Andrew Tropin wrote:>
>>> That said, the evaluator does attach so-called "meta-data" information
>>> to procedures, such as the procedure name.
>>> https://www.gnu.org/software/guile/manual/html_node/Procedure-Properties.html.
>>> If you know that you are making a procedure you can insert some
>>> meta-data for use by your run-time, in an initial vector alist.  See
>>> https://www.gnu.org/software/guile/manual/html_node/Procedure-Properties.html.
>>> But that's limited and doesn't take macros, etc into account.
> 
> Yep, that's is why I wrote:
> 
> --8<---------------cut here---------------start------------->8---
> The another related problem is that the metainformation is stored in
> prodecures properties, but not in variables, which makes it impossible
> to implement a proper goto definition in general case.
> --8<---------------cut here---------------end--------------->8---
> 
> How hard is to make a generic metainformation, which is attachable to
> macros, symbols and other objects of the language, not only to
> procedures?
> 

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.

The attached DrRacket screenshot (of [1]), in which I've tacked a bunch 
of binding arrows, shows how local definitions 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 
Occurrence" will highlight `racket`, because the initial import of the 
racket language establishes the applicable binding of define, whereas 
choosing "Open Defining File" will open the racket/private/kw module, 
and then choosing "Jump to Definition (in Other 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 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].

That said, if you do want to associate extra information with values at 
runtime, Guile has object properties [4], or of course you could always 
keep your own hash table on the side.

Philip

[1]: 
https://github.com/racket/racket/blob/6105332045595f8324985d7a34acc68fa5a61dcf/pkgs/racket-test/tests/json/indent.rkt#L244-L276
[2]: https://www.racket-mode.com/#racket_002dxp_002dmode
[3]: https://github.com/jeapostrophe/racket-langserver/
[4]: 
https://www.gnu.org/software/guile/manual/html_node/Object-Properties.html

[-- Attachment #2: Binding arrows from define-main for indent-test-data-cli 2024-06-26.png --]
[-- Type: image/png, Size: 571391 bytes --]

  reply	other threads:[~2024-06-26 22:06 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 [this message]
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
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=36db048b-2465-4088-b46c-b20e24cd0b66@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).