unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Rocky Bernstein <rocky@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: relative load-file
Date: Thu, 12 Nov 2009 08:01:36 -0500	[thread overview]
Message-ID: <6cd6de210911120501u24047705w5caad5112db6cb45@mail.gmail.com> (raw)
In-Reply-To: <jwvhbt0js59.fsf-monnier+emacs@gnu.org>

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

On Wed, Nov 11, 2009 at 11:22 PM, Stefan Monnier
<monnier@iro.umontreal.ca>wrote:

> > Huh? If I knew a good solution to this short of changing the source code,
> I
> > *wouldn't* be asking.
>
> Here it is then:
>
>  (load (expand-file-name <foo> (file-name-directory
>                                 (or load-file-name buffer-file-name))))
>
> > What strikes me wrong about going in the direction of using
> > buffer-file-name or using buffers is that that we are introspecting
> > about is the running code.
>
> You can't make it work in all cases.  It's simply not possible because
> code exists outside of any notion of file, so "relative file name"
> cannot always make sense.
>

This is a silly argument. It is neither necessary nor desirable to make
load-relative work in cases where it makes no sense. Surely one wouldn't
suggest banning "load" because code can get loaded into Emacs outside of
loading a file.


> So what strikes you as wrong is really a fundamental problem in what
> you're requesting, rather than a problem in the solutions I proposed.
>

Obviously, you think of it that way.

It is becoming clear now that this is something that can be addressed pretty
easily by making a small change to the Emacs source. However, failing that,
the mechanisms for simulating this are a little arcane.



> It's similar in a sense to the issue of a binary executable trying to
> find associated files relative to its own location: in general the
> executable cannot know its own location, so the best you can do is use
> heuristics like look at $0 and search it in $PATH.
>

But there are systems like Scala and Ruby where the running program can find
files relative to its own location! Perhaps part of the reason this feature
was provided is because it was felt that it too many programmers were using
those heuristics to create really ugly and unreliable code; yet it could be
done pretty simply and reliably from the interpreter.

Around the time that Emacs is in readevalloop, it knows very well the file
name that it is working with.

Since we are into analogies, here's how I think of this.

Suppose I have a programming language that doesn't have a debugger because
the run-time support for it is lacking. I suppose then that could say that
asking for debugging  in such a programming language is a fundamental
problem in the request. Verily there are many folks who live without
debuggers. Techniques like test-driven development, modular programming,
proving your program correct, interactive shells, dynamic loading and so on
reduce or I suppose some would say eliminate the need. So sure, one could
argue that the deficiency is in how the programmer programs, not the system.


By the way, in such systems it is sometimes possible to cull together
something that sort of feels like a debugger and so that sometimes happens.


>
> > First, none of the examples I have given do I find really corner case.
>
> They work fine with the above code.
>

Um, no. I cited two kinds of situations that fail with the above code and
both in fact do come up.


> > These and many more have come up. (Recall that I have been using this
> mode
> > of working, and I gather from prior remarks you haven't.)
>
> This mode of working is not encouraged in Emacs.  The main reason is
> probably just historical accident, but the fact that it can't work
> reliably in all cases would be a good reason to retroactively justify
> that choice.
>

Yes, I am very familiar with this kind of good reason. :-)


> > Second, a reason one might try to encapsulate this in a library is to be
> > able to handle as many of the corner cases as possible so run-of-the-mill
> > users need not have to be concerned - they can use the feature and have
> > confidence that it does the right thing.
>
> That would make sense if the functionality was important, but I haven't
> seen evidence that it is.
>

And I'm sorry, but I'm not going to try to convince you.

As I wrote before, folks are happy with the status quo, or at least not too
unhappy with it. So again, thanks for the help. I have a clearer idea of
where things stand now.

Keep up the good work!


>
>
>        Stefan
>

[-- Attachment #2: Type: text/html, Size: 5857 bytes --]

  reply	other threads:[~2009-11-12 13:01 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-11 17:01 relative load-file Rocky Bernstein
2009-11-11 18:35 ` Tassilo Horn
2009-11-11 19:26   ` Rocky Bernstein
2009-11-11 19:54     ` Tassilo Horn
2009-11-11 20:17     ` Stefan Monnier
2009-11-11 21:21       ` Rocky Bernstein
2009-11-11 23:06         ` Stefan Monnier
2009-11-12  1:01           ` Rocky Bernstein
2009-11-12  1:20             ` Stefan Monnier
2009-11-12  2:09               ` Rocky Bernstein
2009-11-12  4:22                 ` Stefan Monnier
2009-11-12 13:01                   ` Rocky Bernstein [this message]
2009-11-12 13:52                     ` spedrosa
2009-11-12 14:11                       ` Andreas Schwab
2009-11-12 15:34                     ` Stefan Monnier
2009-11-13  4:34                       ` Rocky Bernstein
2009-11-13 14:22                         ` Stefan Monnier
2009-11-13 15:03                           ` Rocky Bernstein
2009-11-13 16:17                             ` Stefan Monnier
2009-11-13 16:39                               ` Rocky Bernstein
2009-11-14 11:24 ` Richard Stallman
2009-11-14 15:44   ` Rocky Bernstein
2009-11-15 21:59     ` M Jared Finder
2009-11-18  3:20       ` Stefan Monnier
2009-11-15 22:38     ` Richard Stallman
2009-11-15 23:50       ` Rocky Bernstein
2009-11-18 12:10         ` Richard Stallman
2009-11-18 13:39           ` Rocky Bernstein
2009-11-21 22:52             ` Richard Stallman
2009-11-22  4:45               ` Rocky Bernstein
2009-11-23  2:29                 ` Richard Stallman
2009-11-23 15:04                   ` Rocky Bernstein
2009-11-24 14:11                     ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2009-11-13  5:24 grischka
2009-11-13  5:59 ` Rocky Bernstein
2009-11-13 14:26   ` Stefan Monnier
2009-11-13 15:06     ` Rocky Bernstein

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=6cd6de210911120501u24047705w5caad5112db6cb45@mail.gmail.com \
    --to=rocky@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).