[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: modules, require, magic
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 18 Oct 2011 11:33:50 +0200
On Tue, Oct 18, 2011 at 11:05 AM, Julien Duminil
<julien.duminil@ubisoft.com> wrote:
> require stores "modules" that have already been required in package.loaded[modname] so that if you load the same module twice, it loads it only once:
Yes, it's a brilliant feature that we take for granted. (dofile()
will do exactly what you tell it to do)
$> lua -lpl.utils
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> = package.loaded['pl.utils']
table: 0036BCC0
(as an aside, if you change a module and want to reload inside a
session, then package.loaded['mod'] is what you need to zap to nil to
actually get a re-load.)
Penlight uses some serious voodoo to prevent excessive code loading.
require 'pl' appears to be a kitchen-sink include, but the modules
(such as lapp, tablex, etc) are only loaded on first use. Of course,
module writers and generally careful people don't just say require
'pl' ;)
steve d.
- References:
- modules, require, magic, Eduardo Ochs
- Re: modules, require, magic, Javier Guerra Giraldez
- Re: modules, require, magic, Petite Abeille
- Re: modules, require, magic, Sam Roberts
- Re: modules, require, magic, David Manura
- Re: modules, require, magic, Mark Hamburg
- Re: modules, require, magic, Sean Conner
- Re: modules, require, magic, Josh Simmons
- Re: modules, require, magic, Josh Simmons
- Re: modules, require, magic, steve donovan
- Re: modules, require, magic, Sean Conner
- RE: modules, require, magic, Julien Duminil