Skip to content

Introspection

Marco Aurélio da Silva edited this page Aug 30, 2017 · 2 revisions

Some kind of primitive introspection is provided in this library, but only on talent-level (to not violate any kind of encapsulation on object-level). It also provides some sort of reflection upon objects, querying and "extracting" (without the loss) the current applied talent, only if such object is actually an object provided by this library. The introspection functions for talents are:

talents.requires  (talent1, selector1) --> boolean
talents.provides  (talent2, selector2) --> boolean
talents.conflicts (talent3, selector3) --> boolean

While, the talent query over the object (here, called talent abstraction) is called as:

local talent = talents.abstract (result)

Where:

-- assume again that 'talents' contains the reference to our major module --

local result  = talents.decorate (talent1, object)
local talent2 = talents.abstract (result)

assert (rawequal (talent1, talent2))

Holds for all talent1 existing in the set of talents, and also for all object existing in the set of Lua's objects.

Clone this wiki locally