[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: require inside functions. (was: Changes in calendar/time-date.el)

From: Kim F. Storm
Subject: Re: require inside functions. (was: Changes in calendar/time-date.el)
Date: Fri, 08 Apr 2005 10:12:00 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Richard Stallman <address@hidden> writes:

>     (require 'ft) only loads a file if 'ft is not in features.  However,
>     it unconditionally adds '(require . ft) to current-load-list.  If you
>     call a function with require a million times, this eats up 16 MB of
>     memory.
> This was done deliberately.  The idea is that it's useful
> to record that file foo depends on file bar, even if bar
> was already loaded before foo.

It is not _file_ foo, but _function_ foo that did (require 'bar).

Why is it useful to record that?  For what purpose?

There is no active "load" or "autoload" in progress, so the
require is done in "interactive" context.

> However, it isn't useful to record (require . bar) an additional time
> in current-load-list when it's already there.  So I think the right fix
> is to check with Fmember and not add it a second time.

Which means that (require 'bar) called from a function will definitely
be slowed down (depending on the length of current-load-list)!

Would it work to only add to current-load-list if loading != 0 ?

Kim F. Storm <address@hidden> http://www.cua.dk

reply via email to

[Prev in Thread] Current Thread [Next in Thread]