Module:Buffer/doc explained

This was originally developed to optimize string concatenation as a helper method within, but has been generalized for all modules.

The interface for Module:Buffer objects is similar to that of objects in that you may build complex strings with independent child nodes. In most cases, you may use Buffer objects like a normal string, including using operator. See also:

  1. String, mw.ustring, and mw.text libraries

Additionally, there are several specialized forms and extended objects, described further in their respective sections:

Last but not least, this module has an ordered __pairs which can be more thorough than and . (Even reads nil keys!) The

logical uniqueness of this iterator may be reason enough to Module:Buffer.

Usage

require'Module:Buffer'

Creates a new Module:Buffer object when the module returned by is called as a functioni.e., there is no 'main'.

Because

are a pet peeve of this developer, this forwards arguments to ; if that op is not desired, you may chain a Buffer object function directly to the module and the self-action will be redirected to a new Buffer objecti.e is equivalent to .[1]

The global variable is "magic" when passed as the first arg. Such enables the global functions and, if followed by a name string, will declare the new Buffer with that name in the global scope. If the argument following name is a table with no metatable, it and any other are forwarded to ; otherwise, as long as the first vararg is not nil or false, this passes them to .[2]

Notes and References

  1. For your convenience, the self operator and are interchangeable when used on the Module directly, though the self-op is required for nearly all other interactions with objects created by the Module.
  2. Passing arguments after name is primary used when is indirectly called by or . For example: