class Constant
Constant Value.
Implements the Result and AST inteface.
index
static functions
-
Constant(type, value, raw)
– construct a new Constant. -
Constant:parse(type, sep)
– create a capture-function (for parsing with Lpeg). -
Constant.wrap(val[, name])
– wrap a Lua value. -
Constant.num(num)
– create a constant number. -
Constant.str(str)
– create a constant string. -
Constant.sym(sym)
– create a constant symbol. -
Constant.bool(bool)
– create a constant boolean. -
Constant.bang()
– create a constant bang. -
Constant.meta(args)
– wrap and document a value.
ast interface
-
constant:eval(scope)
– evaluate this literal constant. -
constant:stringify()
– stringify this literal constant. -
constant:clone(prefix)
– clone this literal constant.
result interface
-
constant:dirty()
– return whether this Result was changed in the current tick. -
constant:unwrap([type[, msg]])
– unwrap to the Lua type. -
constant:fork()
– create a mutable copy of this stream. -
constant:__call(...)
– alias for unwrap. -
constant.metatype()
– Result metatype.
details
static functions
- – construct a new Constant.
- – create a capture-function (for parsing with Lpeg).
-
– wrap a Lua value.
Attempts to guess the type and wrap a Lua value.
parameters:
- the value to wrap
- the name of this value (for error logging) (optional)
returns:
- (Constant)
- – create a constant number.
- – create a constant string.
- – create a constant symbol.
- – create a constant boolean.
-
– create a constant bang.
returns:
- (Constant)
- – wrap and document a value.
ast interface
- – evaluate this literal constant.
- – stringify this literal constant.
-
– clone this literal constant.
parameters:
returns:
- (SignStream): self
result interface
-
– return whether this Result was changed in the current tick.
returns:
- (bool)
-
– unwrap to the Lua type.
Asserts
@type == type
if type is given.parameters:
- the type to check for (optional)
- message to throw if type don’t match (optional)
returns:
-
(any):
value
-
– create a mutable copy of this stream.
Used to insulate eval-cycles from each other.
returns:
- (Constant)
-
– alias for unwrap.
parameters:
-
– Result metatype.