unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Neil Jerram <neil@ossau.uklinux.net>
Subject: Re: Modified load-path proposal
Date: Sat, 03 Dec 2005 13:05:12 +0000	[thread overview]
Message-ID: <87y832l4af.fsf@ossau.uklinux.net> (raw)
In-Reply-To: <873bmf4ey4.fsf@laas.fr> ( Ludovic Courtès's message of "Wed, 02 Nov 2005 09:44:03 +0100")

ludovic.courtes@laas.fr (Ludovic Courtès) writes:

> Neil Jerram <neil@ossau.uklinux.net> writes:
>
>> Sorry to have been carrying on this discussion for so long, and for
>> changing direction a couple of times.  If anyone is still reading, I'd
>> appreciate hearing your thoughts (again).
>
> Just a quick note to say:
>
> 0. I'm still reading.  ;-)

Thanks.

> 1. Your `init.d' approach looks very promising and simpler than the one
>    before, which is good.
>
> 2. I'd let the files in the `init.d' directory do a
>    `(require-load-path-directory ...)' rather than just containing the
>    directory name.  A good reason for this is that it is anyway very
>    easy to evaluate those files in a confined environment
>    (e.g. `null-environment' + the `require-load-path-directory'
>    binding).

OK, but aren't (1) and (2) both a bit scuppered by ...

> 3. I'm a bit concerned that this approach is not scalable: opening,
>    reading, and evaluating say a dozen of files each time Guile is
>    started may have a noticeable impact on startup time.

I think you're right.  It makes sense to do something like this for a
long-lived program such as Emacs, or for programs whose interactive
performance is not a concern, such as ifup and cron.  But we'd like
(or at least I'd like) Guile to be used for even very quick scripts,
and it doesn't make sense to increase the start up time of such
scripts by unconditionally loading arbitrary startup code for whatever
other Guile packages are installed.

I think this rules out any kind of iteration through a .d directory
from init.scm.  Apologies for not seeing this consideration before.

>    Maybe those could be loaded lazily, for instance in
>    `try-module-autoload', the first time `%search-load-path' fails.

This would be OK if the package startup file contained only a load
path, and not arbitrary code.  If the startup file was allowed to
contain arbitrary code, that code would presumably be important for
the initialization of the package concerned.  But it would be skipped
if some other circumstance meant that the package's install location
was already in Guile's load path.

Therefore any load-failure-based mechanism for loading startup files
needs to restrict the format of the startup files to just load path
directories.  It also has two disadvantages in my opinion.  Firstly it
feels a bit magic/under the covers/non-deterministic, where I would
prefer something more explicit/deterministic.  Secondly it still has
to unnecessarily load the startup files of all Guile packages on the
system, because it has no way to map the file name or module that
couldn't be loaded to a particular package.

So here's yet another proposal.  We keep the idea of a package
installing a startup file in some directory under $sysconfdir, but we
don't do anything with these in init.scm.  We provide instead:

 -- Scheme Procedure: initialize-packages . package-names
     Load the startup file for each of the packages in PACKAGE-NAMES.
     The startup file for a given package is only loaded once per
     Guile run, so `initialize-packages' avoids loading a package's
     startup file again if it has already been loaded.
     If one of the named packages doesn't have a startup file,
     `initialize-packages' calls `package-startup-file-not-found'
     with the package name as the only argument.  By default
     `package-startup-file-not-found' prints a warning to standard
     output, but you can `set!' it to something else if that is
     more appropriate for your application.

The idea would be for both Guile applications and Guile modules to use
this.  A Guile application should know which packages it uses
(directly), and so can include an appropriate `initialize-packages'
call in its startup script.  Similarly a Guile module knows which
packages it uses, and so can call `initialize-packages' before trying
to use any modules from that package.

(In practice this would mean before the define-module form, but I
don't see anything wrong with that.  For example:

  (initialize-packages "guile-gtk")

  (define-module (ossau widgets)
    #:use-module (gtk gtk)
    ...)

)

I believe this scheme works equally well whether we allow the startup
file to contain arbitrary code, or we restrict it to contain just load
path directories.  If we chose to restrict it, we might want to rename
`initialize-packages' to something more precise, such as
`merge-package-load-paths'.

A possible benefit of the restricted format is that I think we could
write an autoconf macro (for configure.in) that would generate and
install the startup file completely automatically.  But perhaps we can
still do that anyway with the arbitrary code format, and allow it to
be overridden when the package has particular requirements.

So (once again!) please let me know your thoughts.  Is this at last
the answer?

Regards,
        Neil



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


  reply	other threads:[~2005-12-03 13:05 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-13 18:21 Modified load-path proposal Neil Jerram
2005-10-13 18:40 ` Greg Troxel
2005-10-13 22:08   ` Neil Jerram
2005-10-14  0:37     ` Greg Troxel
2005-10-14  1:28       ` Andreas Rottmann
2005-10-15 11:17         ` Neil Jerram
2005-10-15 15:03           ` Greg Troxel
2005-10-15 17:53             ` Neil Jerram
2005-10-22 23:16           ` Kevin Ryde
2005-10-28 17:45             ` Neil Jerram
2005-10-30 18:04               ` Neil Jerram
2005-10-30 18:15                 ` Tomas Zerolo
2005-10-30 20:37                 ` Thien-Thi Nguyen
2005-10-30 22:59                   ` Neil Jerram
2005-10-31 10:55                     ` Thien-Thi Nguyen
2005-10-31 19:22                       ` Neil Jerram
2005-11-08 12:37                         ` Thien-Thi Nguyen
2005-10-31 13:17                   ` Tomas Zerolo
2005-10-30 23:48                 ` Kevin Ryde
2005-10-31 13:20                   ` Tomas Zerolo
2005-10-31 19:20                   ` Neil Jerram
2005-10-31 23:54                     ` Kevin Ryde
2005-11-12  9:47                       ` Neil Jerram
2005-11-01 23:31                     ` Vorfeed Canal
2005-11-12 17:54                       ` Neil Jerram
2005-11-02  8:44                 ` Ludovic Courtès
2005-12-03 13:05                   ` Neil Jerram [this message]
2005-12-13  8:38                     ` Ludovic Courtès
2005-12-16  0:16                       ` Neil Jerram
2005-12-16  1:00                         ` Neil Jerram
2005-12-16  9:55                         ` Ludovic Courtès
2006-01-07 13:37                           ` Neil Jerram
2006-01-11  4:49                             ` steve tell
2006-01-12 18:01                               ` Neil Jerram
2005-10-15 11:24       ` Neil Jerram
2005-10-15 15:01         ` Greg Troxel
2005-10-15 17:49           ` Neil Jerram
2005-10-14  7:24 ` Ludovic Courtès
2005-10-15 11:55   ` Neil Jerram
2005-10-15 15:40     ` Greg Troxel
2005-10-17  8:04       ` Ludovic Courtès
2005-10-17 17:52         ` Greg Troxel
2005-10-18  8:23           ` Search path for C libraries Ludovic Courtès
2005-10-18 10:12             ` Vorfeed Canal
2005-10-17 17:54         ` Modified load-path proposal Neil Jerram
2005-10-18  7:57           ` Ludovic Courtès
2005-10-19 22:30             ` Neil Jerram
2005-10-20  7:56               ` Vorfeed Canal
2005-10-20  8:05               ` Ludovic Courtès
2005-10-20 22:23                 ` Neil Jerram
2005-10-21  7:59                   ` Ludovic Courtès
2005-10-17 18:10       ` Neil Jerram
2005-10-18 16:16         ` Greg Troxel
2005-10-18 21:24           ` Vorfeed Canal
2005-10-19 22:29           ` Neil Jerram

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=87y832l4af.fsf@ossau.uklinux.net \
    --to=neil@ossau.uklinux.net \
    /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).