guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] Eval sets incorrect runtime metainformation


From: Philip McGrath
Subject: Re: [BUG] Eval sets incorrect runtime metainformation
Date: Wed, 26 Jun 2024 18:06:50 -0400
User-agent: Mozilla Thunderbird

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: Binding arrows from define-main for indent-test-data-cli 2024-06-26.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]