> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Closures

> Periksa, buat, kloning, dan ganti penutupan.

<div className="real-category-page">
  Periksa, buat, kloning, dan ganti penutupan.

  ## Fungsi yang tersedia

  <CardGroup cols={2}>
    <Card title="checkcaller" href="./checkcaller">
      Mengembalikan apakah current Luau thread ada di Real caller context. Function tidak menerima arguments dan mendorong boolean result dari the current caller context. Function tidak memeriksa Lua call stack atau function object.
    </Card>

    <Card title="clonefunction" href="./clonefunction">
      Creates and returns a separate function value for the function passed as the first argument. The argument must be a function.
    </Card>

    <Card title="comparefunctions" href="./comparefunctions">
      Membandingkan dua function values berdasarkan function identity. Kedua arguments harus berupa functions. Function mengembalikan boolean result dari function identity(L, 1) == function identity(L, 2). Function tidak membandingkan function bytecode, source, behavior, hashes, upvalues, atau newcclosure mappings. comparefunction adalah alias untuk function yang sama.
    </Card>

    <Card title="getfunctionhash" href="./getfunctionhash">
      Returns an uppercase SHA384 hex digest derived from a Luau function. The argument must be a function, and C closures raise "Lua function expected". If no hashable function content is available, the function returns nil.
    </Card>

    <Card title="hookfunction" href="./hookfunction">
      Melakukan hook pada target function dengan replacement function dan mengembalikan cloned copy dari original target closure. Kedua arguments harus berupa functions. Function pertama melakukan flush pending C function swaps, melakukan cloning target melalui function cloning, menambahkan replacement closure atau mapped newcclosure target miliknya ke hidden stack tracking, memanggil FixCallstack untuk target dan cloned original, lalu melakukan patch target closure melalui C closure, Luau closure, atau newcclosure-specific path. Jika target belum ada di hook records, cloned original disimpan di sana untuk restorefunction. Returned function adalah cloned original closure.
    </Card>

    <Card title="hookmetamethod" href="./hookmetamethod">
      Mencari metamethod function pada value dan melakukan hook pada function tersebut melalui hookfunction. First argument dapat berupa value apa pun yang diterima raw metafield lookup. Second argument harus berupa string metamethod name, dan third argument harus berupa function replacement. Jika raw metafield lookup tidak menemukan named metafield, function memunculkan "Metamethod doesn't exist" untuk argument 2. Jika metafield ada tetapi bukan function, function memunculkan "Metamethod isn't a function" untuk argument 2. Saat metafield adalah function, hookmetamethod memanggil hookfunction dengan found metamethod function sebagai target dan mengembalikan cloned original closure dari hookfunction.
    </Card>

    <Card title="iscclosure" href="./iscclosure">
      Returns whether the provided function is a C closure. The argument must be a function; passing any other type raises a type error. The function does not inspect executor ownership, source, bytecode, or upvalues.
    </Card>

    <Card title="isexecutorclosure" href="./isexecutorclosure">
      Returns whether the provided function is classified as executor-owned. The argument must be a function. The function does not inspect source text, debug names, bytecode hashes, or call stack ownership.
    </Card>

    <Card title="isfunctionhooked" href="./isfunctionhooked">
      Returns whether the provided function currently has a hook record. The argument must be a function.
    </Card>

    <Card title="ishiddenstack" href="./ishiddenstack">
      Returns whether a function, or the function at a stack level, is marked as hidden. target must be a function or stack level number. Invalid stack levels raise "Level out of range". isstackhidden is an alias.
    </Card>

    <Card title="islclosure" href="./islclosure">
      Returns whether the provided function is a Lua closure. The argument must be a function; passing a non-function raises a type error. isluaclosure is an alias.
    </Card>

    <Card title="isnewcclosure" href="./isnewcclosure">
      Returns whether the provided function is a newcclosure-created C closure. The first argument must be a function; passing a non-function raises a type error. Documented usage is a single function argument; extra arguments are not part of the supported signature.
    </Card>

    <Card title="newcclosure" href="./newcclosure">
      Returns a C closure for the provided function. If the function is already a C closure, the same function is returned. Passing a non-function raises a type error.
    </Card>

    <Card title="newlclosure" href="./newlclosure">
      Returns a Luau closure that calls the provided function. The first argument must be a function.
    </Card>

    <Card title="restorefunction" href="./restorefunction">
      Memulihkan atau mengganti function dengan memanggil function hook operation secara dan tidak mengembalikan values. First argument harus berupa function. Dengan satu function argument, function mencari the saved original function; jika tidak ada entry, function memunculkan "Function is not hooked". Lalu function memanggil function hook operation dengan hooked closure dan stored original closure, fieldsihkan Lua stack, dan menghapus restored closure dari hook records saat stored original digunakan. Jika second argument juga function, function memperlakukan firstFunction sebagai original function yang akan dipasang dan secondFunction sebagai closure yang akan di-patch. Dalam bentuk itu, tidak ada missing-original check terhadap nilai hook records yang tersimpan; nilai tersimpan hanya dibandingkan selama final remove check. Non-function second arguments diabaikan oleh branch condition. restorefunc dan restoreclosure adalah aliases untuk function yang sama.
    </Card>

    <Card title="sethiddenstack" href="./sethiddenstack">
      Marks or unmarks a function, or the function at a stack level, as hidden. target must be a function or stack level number. hidden defaults to true. Invalid stack levels raise "Level out of range". setstackhidden is an alias.
    </Card>
  </CardGroup>
</div>
