Module strictness
strictness, a "strict" mode for Lua.
Source on Github
Info:
- Copyright: 2013-2014
- License: MIT
- Author: Roland Yonaba
Functions
strict ([t[, ...]]) | Makes a given table strict. |
is_strict (t) | Checks if a given table is strict. |
unstrict (t) | Makes a given table non-strict. |
strictf (f) | Creates a strict function. |
unstrictf (f) | Creates a non-strict function. |
run_strict (f[, ...]) | Returns the result of a function call in strict mode. |
run_unstrict (f[, ...]) | Returns the result of a function call in non-strict mode. |
Functions
- strict ([t[, ...]])
-
Makes a given table strict. It mutates the passed-in table (or creates a
new table) and returns it. The returned table is strict, indexing or
assigning undefined fields will raise an error.
Parameters:
- t a table
- ... a vararg list of allowed fields in the table.
Returns:
-
the passed-in table
t
or a new table, patched to be strict.Usage:
local t = strictness.strict() local t2 = strictness.strict({}) local t3 = strictness.strict({}, 'field1', 'field2')
- is_strict (t)
-
Checks if a given table is strict.
Parameters:
- t a table
Returns:
true
if the table is strict,false
otherwise.Usage:
local is_strict = strictness.is_strict(a_table)
- unstrict (t)
-
Makes a given table non-strict. It mutates the passed-in table and
returns it. The returned table is non-strict.
Parameters:
- t a table
Usage:
local unstrict_table = strictness.unstrict(trict_table)
- strictf (f)
-
Creates a strict function. Wraps the given function and returns the wrapper.
The new function will always run in strict mode in its environment, whether
or not this environment is strict.
Parameters:
- f a function, or a callable value.
Usage:
local strict_f = strictness.strictf(a_function) local result = strict_f(...)
- unstrictf (f)
-
Creates a non-strict function. Wraps the given function and returns the wrapper.
The new function will always run in non-strict mode in its environment, whether
or not this environment is strict.
Parameters:
- f a function, or a callable value.
Usage:
local unstrict_f = strictness.unstrictf(a_function) local result = unstrict_f(...)
- run_strict (f[, ...])
-
Returns the result of a function call in strict mode.
Parameters:
- f a function, or a callable value.
- ...
a vararg list of arguments to function
f
.
Usage:
local result = strictness.run_strict(a_function, arg1, arg2)
- run_unstrict (f[, ...])
-
Returns the result of a function call in non-strict mode.
Parameters:
- f a function, or a callable value.
- ...
a vararg list of arguments to function
f
.
Usage:
local result = strictness.run_unstrict(a_function, arg1, arg2)