Computed Datatypes
Computed Datatypes are similar to light.literal()
and
light.enum()
, except they are a function which returns a
Datatype. They are mostly useful for
LinkedList, and are best paired with
Cached Datatypes.
Introducing external conditionality to serialization / deserialization can be dangerous. Please be careful.
You should never yield from within datatypes.computed()
's lambda callback(s).
This is considered undefined behavior.
You should never send any message from within datatypes.computed()
's lambda callback(s).
This is considered undefined behavior.
datatypes.computed()
allows for recursive types.
If you pass a self-referential table, serialization may hang forever.
No implicit declarations
Returning implicitly defined
Datatypes, such as
Table Syntax, will not work. You
must return
an explicitly defined Datatype. To get around this, you can use
datatypes.cached()
function light.datatypes.computed
An example LinkedList Datatype
using datatypes.computed()
and Cached Datatypes: