newlclosure

Wraps a C closure to appear as a Luau closure.

Syntax

newlclosure(func: function, debugname?: string) -> function

Parameters

ParameterTypeDescription
funcfunctionThe C closure to wrap
debugnamestring?Optional debug name for the wrapper

Returns

TypeDescription
functionA Luau closure wrapper that calls the original function

Description

newlclosure wraps a C closure so that it appears to be a Luau closure when inspected. The wrapped function behaves identically but islclosure will return true for it.

Example

-- print is a C closure
print(iscclosure(print)) -- true
print(islclosure(print)) -- false

-- Wrap it as a Luau closure
local wrappedPrint = newlclosure(print)

-- Now it appears as a Luau closure
print(iscclosure(wrappedPrint)) -- false
print(islclosure(wrappedPrint)) -- true

-- But still works the same
wrappedPrint("Hello!") -- Output: Hello!