[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Require (4.1-work)
- From: Jean-Claude Wippler <jcw@...>
- Date: Thu, 10 May 2001 01:02:46 -0700
The new "require('file')" is cool. It tracks already-loaded files
and avoids a re-load, so that one can use require calls everywhere.
For example, with these files:
The following happens:
% lua ah
% lua ha
% lua ha ha
However, normal loading does not mark the file as loaded:
% lua ah ha
ah <- this is a bit of a surprise
% luac -o aha ah ha
% lua aha
ah <- so is this
Maybe it is preferable to make "dofile" also mark the file as loaded?
This has the benefit that a main script called "m", calling three
other scripts "a", "b", and "c", can then be compiled as follows:
% luac -o m.out a b c m
If "m" contains:
require "a"; require "b"; require "c"
<do something useful>
then "lua m" and "lua m.out" would do the same thing.
Another question: why was "require" coded in C, and not in Lua?