Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 1.35 KB

$.md

File metadata and controls

31 lines (22 loc) · 1.35 KB

require'$'

Loads the minimum amount of modules that every Lua application seems to need and makes a lot of symbols global. Think of it as emptying all your tool boxes on the floor before you start a job. Some people feel more efficient doing it like that, others hate it, wacha gonna do.

Libraries don't use this module in an attempt to lower dependency count, avoid polluting the global namespace and improve code readability. Apps don't care about all that and would rather establish a base vocabulary to use everywhere, so this module can be useful when building an app, less so when making a library.

What libraries usually do instead of loading this module:

  • require the ffi module every goddamn time (and maybe the bit module).
  • copy-paste a few tools from [glue] to avoid bringing in the whole kitchen.
  • put used symbols into locals (also for speed when code is interpreted).

All that is wasted effort on an app, where you already established your dependencies so anyone who wants to work on your code needs to be familiar with them dependencies beforehand.

Note that the standard Lua module function is replaced with a function with entirely different semantics (see glue for that).

TIP: Run the script standalone with luajit $.lua to get a listing of all the symbols (which you can then paste into your editor config file for syntax highlighting).