unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "T.V Raman" <raman@google.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Alan Mackenzie <acm@muc.de>,  Eli Zaretskii <eliz@gnu.org>,
	emacs-devel@gnu.org
Subject: Re: How does one find out what file a library has been loaded from?
Date: Sun, 24 Jul 2022 08:49:51 -0700	[thread overview]
Message-ID: <p91y1wifr34.fsf@google.com> (raw)
In-Reply-To: <jwvr12azgyz.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 24 Jul 2022 11:32:29 -0400")

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030, Size: 3818 bytes --]

Stefan Monnier <monnier@iro.umontreal.ca> writes:

In that context, how does find-function work?

>> I just don't understand you saying that the information is still correct.
>> In about "half" the cases, when a .eln file has been loaded, the current
>> text in the Elisp manual and load-history doc string is no longer
>> correct.  The file given in load-history is not the file that was loaded
>> into Emacs.
>
> Because of the design decision to make native code compilation
> transparent, `load-history` does not mean "this is exactly the file that
> was loaded directly" but rather something like: "this is the file from
> which we loaded the definitions, tho the path to loading them may
> include turning the code into some other representation such a native
> code, while being (hopefully) faithful to the file's semantics".
>
> So if you actually need to know more precisely where the code comes
> from, you need to look at supplemental information (such as the one
> Andrea gave you).
>
>>> > > Did you try comp-el-to-eln-filename?
>>> > No.  How could I have known that such a function exists?
>>> I just told you about it.  I told you about it not as an accusation,
>>> but as a way to help you find the best way of solving your problem.
>> OK, thanks.  But I still don't think I could have found out the existence
>> of this function without asing "are there any relevant
>> functions/variables to what I'm trying to do?".
>
> Which is why your effort to try and document this is worthwhile, indeed.
> [ It may also inform improvements to the API to make it easier to find,
>   but documenting the status quo is an indispensable first step.  ]
>
>>> Then I think you should describe the purpose better and in more detail.
>> I simply wish to know the file from which a function has been loaded, or
>> the loaded file corresponding to some source file.
>
> "I" as in "I the human being", and "simply" as in "out of pure curiosity"?
> What are you going to do with that knowledge?  Would you be satisfied
> with knowing only if it's native code rather than byte code (rather
> than see the gory file name with all its hashes and stuff)?
>
>> I would like to know whether this file is a source file, a .elc, or
>> a .eln.
>
> `C-h o <function> RET` should tell you that without needing any knowledge
> of ELisp.  Admittedly, it doesn't quite satisfy your requirements since
> the input is now a function name rather than a file name.
>
>>> What exactly are you trying to accomplish and why?
>> There are lots of reasons I might want to know the loaded file, some of
>> which have already come up in the thread.  I might want to be sure I've
>> built Emacs with native compilation.
>
> I think the canonical way to test this is
>
>     (featurep 'native-compile)
>
>> I might be interested in benchmarking or RAM occupancy.
>
> I don't see the connection, but `subrp` or `byte-code-function-p` or
> just printing the output of `symbol-function` on a relevant function
> should tell you how your code was compiled.  No need for any file name.
>
>>> What is the data from which you start and what is the data you want to
>>> obtain as result?
>> The name of a source file or function, and the name of the matching file
>> which was loaded.
>
> Wanting a "matching file" is IMO the result of your mental model not
> firmed up enough yet, then :-)
>
> After all, even if the answer is a nasty `.../blabla.eln` you still
> won't know whether your function is implemented as native code since
> that `.eln` can contain (and generate) byte code.  And that's not
> just theory, it does happen in practice.
>
>
>         Stefan
>
>

-- 

Thanks,

--Raman(I Search, I Find, I Misplace, I Research)
7©4 Id: kg:/m/0285kf1  •0Ü8



  reply	other threads:[~2022-07-24 15:49 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19 10:52 How does one find out what file a library has been loaded from? Alan Mackenzie
2022-07-19 12:39 ` Eli Zaretskii
2022-07-19 15:01   ` Alan Mackenzie
2022-07-19 15:32     ` Andrea Corallo
2022-07-24 16:07       ` Eli Zaretskii
2022-07-24 17:46         ` Andrea Corallo
2022-07-31 12:52           ` Eli Zaretskii
2022-08-01  9:23             ` Andrea Corallo
2022-08-02  8:43               ` Andrea Corallo
2022-08-02 12:12                 ` Eli Zaretskii
2022-08-02 14:13                   ` Andrea Corallo
2022-08-03 14:19                     ` Eli Zaretskii
2022-08-01 19:31             ` Alan Mackenzie
2022-08-03 14:16               ` Eli Zaretskii
2022-07-19 15:50     ` Eli Zaretskii
2022-07-19 17:07       ` Alan Mackenzie
2022-07-19 19:13         ` Eli Zaretskii
2022-07-20 11:47           ` Alan Mackenzie
2022-07-20 15:31             ` Stefan Monnier
2022-07-20 20:34             ` Alan Mackenzie
2022-07-21  6:13               ` Eli Zaretskii
2022-07-21 17:37                 ` Alan Mackenzie
2022-07-21 17:52                   ` Stefan Monnier
2022-07-21 18:24                     ` Alan Mackenzie
2022-07-21 18:37                       ` Stefan Monnier
2022-07-21 21:03                         ` Alan Mackenzie
2022-07-21 23:15                           ` Stefan Monnier
2022-07-21 17:53                   ` Eli Zaretskii
2022-07-21 20:39                     ` Alan Mackenzie
2022-07-23 10:11                       ` Eli Zaretskii
2022-07-24 11:27                         ` Alan Mackenzie
2022-07-24 12:16                           ` Eli Zaretskii
2022-07-24 15:37                             ` Eli Zaretskii
2022-07-24 15:42                               ` Eli Zaretskii
2022-07-24 15:32                           ` Stefan Monnier
2022-07-24 15:49                             ` T.V Raman [this message]
2022-07-24 16:11                               ` Stefan Monnier
2022-07-24 18:21                                 ` T.V Raman
2022-07-24 18:50                                   ` Stefan Monnier
2022-07-24 16:19                               ` Eli Zaretskii
2022-07-19 16:27     ` Stefan Monnier
2022-07-20 18:36       ` Andrea Corallo
2022-07-21  7:20         ` Eli Zaretskii

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/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=p91y1wifr34.fsf@google.com \
    --to=raman@google.com \
    --cc=acm@muc.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).