Volt

newlclosure

Wraps a C closure to appear as a Luau closure.

Syntax

newlclosure(func: function) -> function

Parameters

ParameterTypeDescription
funcfunctionThe C closure to wrap

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!

Notes

  • The wrapper has minimal performance overhead

On this page