unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Rocky Bernstein <rocky@gnu.org>
To: rms@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: relative load-file
Date: Wed, 18 Nov 2009 08:39:11 -0500	[thread overview]
Message-ID: <6cd6de210911180539j6c921924t36a8eeda3a5a22fb@mail.gmail.com> (raw)
In-Reply-To: <E1NAjMl-0003pD-Ek@fencepost.gnu.org>

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

On Wed, Nov 18, 2009 at 7:10 AM, Richard Stallman <rms@gnu.org> wrote:

>    require-relative allows me to load or eval and test any one of the
> subparts
>    without mucking with the load path yet ensure I am getting the right
> files
>    loaded.
>
> I see.  It is for when the program is NOT installed.
>

I am not sure you see. For me, installation is kind of a sketchy thing -
several different versions of a program may be "installed".  Furthermore,
testing, debugging, or running subparts in one of those "installations" for
me is no different than testing when the program is "not installed".

So for me, one thing that make a programming development agile is reducing
the overhead and distinction of this "install" step.


>
> But suppose it were enough had to add one parent directory to
> load-path, for instance ~/elisp, and you put all your directories of
> Lisp programs under that.  Suppose that you specify `foo/bar', and it
> would find that under ~/elisp.
>

load-path may be fine for finding initially where to get a package. However
it is cumbersome and unnecessary for referring to the submodules of a
program from inside the source code.

In compiled languages this distinction is pretty clear. For example in C one
doesn't confuse PATH with INCLUDE_PATH. And note that I can write #include
"./stidio.h" as well as #include <stdio.h> which are very different things;
both are equally valid and used.


> Would that be easy and reliable enough?
>

Well, let's check out the possibilities.

Do I write my program with subparts to assume that "." is first in the load
path? I not, and I just assume "." is first, then my program can break *at
run time *if that assumption is not valid.

Okay, so now suppose I check, and possibly add something like "." (And here
__FILE__ not "." would the most reliable thing to use) and finally remove it
someplace in the code where I know I don't need to load any more files. Now
my program is more clumsy. Furthermore it is possible I might not get those
stereotypical steps right. And I suppose I need to worry about error cases:
if load-path is added and some error condition is raised, I should make sure
that my addition is removed.

For these two reasons it sounds like it would be good to write a package to
do these steps.  But then, why do I need load-path at all? For internal
module loading, what *benefit* is it serving?

And so  that's what I've done. What makes this a little unreliable right now
is the fact that there isn't a solid definition of __FILE__, though the
package I guess is providing one which over time will get better.

Since people's heads explode at the idea of adding __FILE__ because as has
been noted there are some situations where it makes no sense, suppose
load-file-name is *extended* to include more cases.

load-file-name already returns nil in some situations, so I guess people may
be less put off it it returns nil is a couple fewer cases such being called
from eval-buffer.

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

  reply	other threads:[~2009-11-18 13:39 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
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 [this message]
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=6cd6de210911180539j6c921924t36a8eeda3a5a22fb@mail.gmail.com \
    --to=rocky@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rms@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.
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).