From: Andy Wingo <wingo@pobox.com>
To: "Diogo F. S. Ramos" <dfsr@riseup.net>
Cc: guile-user@gnu.org
Subject: Re: Description of `program-sources' and accessors
Date: Tue, 22 Apr 2014 21:31:51 +0200 [thread overview]
Message-ID: <87d2g9ma8o.fsf@pobox.com> (raw)
In-Reply-To: <87tx9le2nb.fsf@nebulosa.milkyway> (Diogo F. S. Ramos's message of "Tue, 22 Apr 2014 13:43:04 -0300")
On Tue 22 Apr 2014 18:43, "Diogo F. S. Ramos" <dfsr@riseup.net> writes:
>>> I'm using this interface to know where an object has been defined.
>>
>> What does this mean? (Have you seen the (system xref) facility? It
>> doesn't do a good job with non-procedures, but perhaps we could change
>> that.)
>
> Thank you for the reference. `procedure-callees' and
> `procedure-callers' are very useful.
>
> For what I mean, I want to know the source file and line where an object
> has been defined. For example:
>
> (object-location (module-ref (current-module) 'procedure-callees)) =>
> ((file . "/path/to/module/system/xref.scm") (line . 89))
>
> I couldn't figure out how to achieve it with (system xref) but after
> your explanation, I'm using the VMs interface, hence my previous
> question.
I see. Indeed, you need to use (program-source proc 0) currently, for
procedures. For non-procedure objects there's currently no way to know
where they're defined, and indeed it's tricky. E.g.:
(define foo '(1 2 3))
(define bar '(1 2 3))
Since these are literals they share storage, so you can't tell whether
the value that `foo' evaluates to proceeded from the "foo" definition or
the "bar" definition. Then there are immediates like fixnums, etc,
which obviously can't be traced to their definitions.
On the other hand it is probably possible to know where a name "foo" in
a module (bar) is defined, through VM internals. Not currently
implemented. But that's a mapping from fully-qualified _names_ to
locations, not values to locations.
Regards,
Andy
--
http://wingolog.org/
next prev parent reply other threads:[~2014-04-22 19:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-19 10:07 Description of `program-sources' and accessors Diogo F. S. Ramos
2014-04-19 11:43 ` Andy Wingo
2014-04-20 18:09 ` Diogo F. S. Ramos
2014-04-22 8:27 ` Andy Wingo
2014-04-22 16:43 ` Diogo F. S. Ramos
2014-04-22 19:31 ` Andy Wingo [this message]
2014-04-22 22:09 ` Diogo F. S. Ramos
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=87d2g9ma8o.fsf@pobox.com \
--to=wingo@pobox.com \
--cc=dfsr@riseup.net \
--cc=guile-user@gnu.org \
/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).