Cached
In light, you can use lua table syntax to represent a Datatype, and it'll be converted automatically when you use it in a Message.
This API exists to manually cache the result of a Datatype. This will internally turn it into a numeric ID if it isn't one already, rendering it unusable for anything other than ser/des and messages. Messages cache their Datatypes automatically, but this can be useful in conjunction with other features like Computed Datatypes.
function light.datatypes.cached
An example
LinkedList Datatype
using datatypes.cached()
and datatypes.computed()
:
light.computed()
allows for recursive types.
If you pass a self-referential table, serialization may hang forever.