lua-users home
lua-l archive

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


2010/6/24 Fernando P. García <fernando@develcuy.com>:
> Let me add a question, which one is better according to the use case?
> better: faster, less memory footprint, vs. better: more convenient, less
> prone to errors.
>

<opinion>
If you know exactly where the file is, it's part of your code (as
opposed to an external library you're using), and if you're okay with
being able to run the file multiple times, dofile() might be the
better choice. If you're using an external library, you'll probably
want require(), with the added feature that it caches the return value
of the module so every subsequent require() won't spend extra time
running the same file (which would often be a bad idea anyways).
</opinion>

Keep in mind, you can also edit your own paths into package.path and
package.cpath to meet your needs.

~Jonathan