On 2024-06-26 18:06, Philip McGrath wrote: > 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. If you could share a snippet of code or link to related library or docs, it could help to understand better the idea. I still relatively newbie in questions related to snyntax objects and overall scheme's expand. > > 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. Thank you for pointing to object properties! I guess we can implement our own eval, to attach location information to corresponding objects, I just expected it to be a part of the guile, because we already have this information for procedures anyway. The another problem with our own eval is that information for already loaded code won't be enriched with our custom stuff :/ > > 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 > x -- Best regards, Andrew Tropin