Yuari
Documentation
Docs/Closures/newcclosure

newcclosure

Wraps a Lua function as a C closure.

Syntax

newcclosure(fn: function) -> function

Parameters

ParameterTypeDescription
fnfunctionThe function or callback to use.

Returns

TypeDescription
functionThe returned function.

Description

newcclosure is part of the Closures library. Closure helpers operate on live Luau function objects. Hooks redirect future calls through the replacement closure and return the previous implementation.

Each call creates or returns a fresh object or value that you can store and pass to other functions.

Example

local fn = newcclosure(function(value)
    return value + 1
end)
print(fn(1))

Notes

  • Closure operations act on live Luau function objects; installed hooks remain active until restored.