isnewcclosure
Returns whether a function is the result of a newcclosure call.
function isnewcclosure(func: function): booleanSynopsis
How it works
Checks whether
func is a CClosure that was specifically created by the executor's newcclosure implementation. Regular C closures (like print or math.abs) return false. Only closures tagged internally by the executor's newcclosure allocator return true.Under the hood
The executor tags newcclosure-created closures with an internal marker (typically a special upvalueUpvalueA variable captured from an enclosing scope. When a function references a local variable from an outer function, that variable becomes an upvalue — stored in an UpVal struct that persists even after the outer function returns. or flag on the
CClosure struct). isnewcclosure checks for this marker, distinguishing executor-wrapped closures from genuine native C functions.Usage
Check newcclosure
function a()
print("Hello World!")
end
print(isnewcclosure(a)) "cc">--> false
local b = newcclosure(a)
print(isnewcclosure(b)) "cc">--> trueParameters
func function The function to check.
Returns
boolean true if the function was created by newcclosure.