extensions.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Extensions</title>
  5. <meta charset="utf-8">
  6. <meta name="Copyright" content="Copyright (C) 2005-2025">
  7. <meta name="Language" content="en">
  8. <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
  9. <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
  10. <style type="text/css">
  11. table.exc {
  12. line-height: 1.2;
  13. }
  14. tr.exchead td {
  15. font-weight: bold;
  16. }
  17. td.excplatform {
  18. width: 48%;
  19. }
  20. td.exccompiler {
  21. width: 29%;
  22. }
  23. td.excinterop {
  24. width: 23%;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div id="site">
  30. <a href="https://luajit.org"><span>Lua<span id="logo">JIT</span></span></a>
  31. </div>
  32. <div id="head">
  33. <h1>Extensions</h1>
  34. </div>
  35. <div id="nav">
  36. <ul><li>
  37. <a href="luajit.html">LuaJIT</a>
  38. <ul><li>
  39. <a href="https://luajit.org/download.html">Download <span class="ext">&raquo;</span></a>
  40. </li><li>
  41. <a href="install.html">Installation</a>
  42. </li><li>
  43. <a href="running.html">Running</a>
  44. </li></ul>
  45. </li><li>
  46. <a class="current" href="extensions.html">Extensions</a>
  47. <ul><li>
  48. <a href="ext_ffi.html">FFI Library</a>
  49. <ul><li>
  50. <a href="ext_ffi_tutorial.html">FFI Tutorial</a>
  51. </li><li>
  52. <a href="ext_ffi_api.html">ffi.* API</a>
  53. </li><li>
  54. <a href="ext_ffi_semantics.html">FFI Semantics</a>
  55. </li></ul>
  56. </li><li>
  57. <a href="ext_buffer.html">String Buffers</a>
  58. </li><li>
  59. <a href="ext_jit.html">jit.* Library</a>
  60. </li><li>
  61. <a href="ext_c_api.html">Lua/C API</a>
  62. </li><li>
  63. <a href="ext_profiler.html">Profiler</a>
  64. </li></ul>
  65. </li><li>
  66. <a href="https://luajit.org/status.html">Status <span class="ext">&raquo;</span></a>
  67. </li><li>
  68. <a href="https://luajit.org/faq.html">FAQ <span class="ext">&raquo;</span></a>
  69. </li><li>
  70. <a href="https://luajit.org/list.html">Mailing List <span class="ext">&raquo;</span></a>
  71. </li></ul>
  72. </div>
  73. <div id="main">
  74. <p>
  75. LuaJIT is fully upwards-compatible with Lua 5.1. It supports all
  76. <a href="https://www.lua.org/manual/5.1/manual.html#5"><span class="ext">&raquo;</span>&nbsp;standard Lua
  77. library functions</a> and the full set of
  78. <a href="https://www.lua.org/manual/5.1/manual.html#3"><span class="ext">&raquo;</span>&nbsp;Lua/C API
  79. functions</a>.
  80. </p>
  81. <p>
  82. LuaJIT is also fully ABI-compatible to Lua 5.1 at the linker/dynamic
  83. loader level. This means you can compile a C&nbsp;module against the
  84. standard Lua headers and load the same shared library from either Lua
  85. or LuaJIT.
  86. </p>
  87. <p>
  88. LuaJIT extends the standard Lua VM with new functionality and adds
  89. several extension modules. Please note, this page is only about
  90. <em>functional</em> enhancements and not about performance enhancements,
  91. such as the optimized VM, the faster interpreter or the JIT compiler.
  92. </p>
  93. <h2 id="modules">Extensions Modules</h2>
  94. <p>
  95. LuaJIT comes with several built-in extension modules:
  96. </p>
  97. <h3 id="bit"><tt>bit.*</tt> &mdash; Bitwise operations</h3>
  98. <p>
  99. LuaJIT supports all bitwise operations as defined by
  100. <a href="https://bitop.luajit.org"><span class="ext">&raquo;</span>&nbsp;Lua BitOp</a>:
  101. </p>
  102. <pre class="code">
  103. bit.tobit bit.tohex bit.bnot bit.band bit.bor bit.bxor
  104. bit.lshift bit.rshift bit.arshift bit.rol bit.ror bit.bswap
  105. </pre>
  106. <p>
  107. This module is a LuaJIT built-in &mdash; you don't need to download or
  108. install Lua BitOp. The Lua BitOp site has full documentation for all
  109. <a href="https://bitop.luajit.org/api.html"><span class="ext">&raquo;</span>&nbsp;Lua BitOp API functions</a>.
  110. The FFI adds support for
  111. <a href="ext_ffi_semantics.html#cdata_arith">64&nbsp;bit bitwise operations</a>,
  112. using the same API functions.
  113. </p>
  114. <p>
  115. Please make sure to <tt>require</tt> the module before using any of
  116. its functions:
  117. </p>
  118. <pre class="code">
  119. local bit = require("bit")
  120. </pre>
  121. <p>
  122. An already installed Lua BitOp module is ignored by LuaJIT.
  123. This way you can use bit operations from both Lua and LuaJIT on a
  124. shared installation.
  125. </p>
  126. <h3 id="ffi"><tt>ffi.*</tt> &mdash; FFI library</h3>
  127. <p>
  128. The <a href="ext_ffi.html">FFI library</a> allows calling external
  129. C&nbsp;functions and the use of C&nbsp;data structures from pure Lua
  130. code.
  131. </p>
  132. <h3 id="jit"><tt>jit.*</tt> &mdash; JIT compiler control</h3>
  133. <p>
  134. The functions in this module
  135. <a href="ext_jit.html">control the behavior of the JIT compiler engine</a>.
  136. </p>
  137. <h3 id="c_api">C API extensions</h3>
  138. <p>
  139. LuaJIT adds some
  140. <a href="ext_c_api.html">extra functions to the Lua/C API</a>.
  141. </p>
  142. <h3 id="profiler">Profiler</h3>
  143. <p>
  144. LuaJIT has an <a href="ext_profiler.html">integrated profiler</a>.
  145. </p>
  146. <h2 id="library">Enhanced Standard Library Functions</h2>
  147. <h3 id="xpcall"><tt>xpcall(f, err [,args...])</tt> passes arguments</h3>
  148. <p>
  149. Unlike the standard implementation in Lua 5.1, <tt>xpcall()</tt>
  150. passes any arguments after the error function to the function
  151. which is called in a protected context.
  152. </p>
  153. <h3 id="load"><tt>load*()</tt> handle UTF-8 source code</h3>
  154. <p>
  155. Non-ASCII characters are handled transparently by the Lua source code parser.
  156. This allows the use of UTF-8 characters in identifiers and strings.
  157. A UTF-8 BOM is skipped at the start of the source code.
  158. </p>
  159. <h3 id="load_mode"><tt>load*()</tt> add a mode parameter</h3>
  160. <p>
  161. As an extension from Lua 5.2, the functions <tt>loadstring()</tt>,
  162. <tt>loadfile()</tt> and (new) <tt>load()</tt> add an optional
  163. <tt>mode</tt> parameter.
  164. </p>
  165. <p>
  166. The default mode string is <tt>"bt"</tt>, which allows loading of both
  167. source code and bytecode. Use <tt>"t"</tt> to allow only source code
  168. or <tt>"b"</tt> to allow only bytecode to be loaded.
  169. </p>
  170. <p>
  171. By default, the <tt>load*</tt> functions generate the native bytecode format.
  172. For cross-compilation purposes, add <tt>W</tt> to the mode string to
  173. force the 32 bit format and <tt>X</tt> to force the 64 bit format.
  174. Add both to force the opposite format. Note that non-native bytecode
  175. generated by <tt>load*</tt> cannot be run, but can still be passed
  176. to <tt>string.dump</tt>.
  177. </p>
  178. <h3 id="tostring"><tt>tostring()</tt> etc. canonicalize NaN and &plusmn;Inf</h3>
  179. <p>
  180. All number-to-string conversions consistently convert non-finite numbers
  181. to the same strings on all platforms. NaN results in <tt>"nan"</tt>,
  182. positive infinity results in <tt>"inf"</tt> and negative infinity results
  183. in <tt>"-inf"</tt>.
  184. </p>
  185. <h3 id="tonumber"><tt>tonumber()</tt> etc. use builtin string to number conversion</h3>
  186. <p>
  187. All string-to-number conversions consistently convert integer and
  188. floating-point inputs in decimal, hexadecimal and binary on all platforms.
  189. <tt>strtod()</tt> is <em>not</em> used anymore, which avoids numerous
  190. problems with poor C library implementations. The builtin conversion
  191. function provides full precision according to the IEEE-754 standard, it
  192. works independently of the current locale and it supports hex floating-point
  193. numbers (e.g. <tt>0x1.5p-3</tt>).
  194. </p>
  195. <h3 id="string_dump"><tt>string.dump(f [,mode])</tt> generates portable bytecode</h3>
  196. <p>
  197. An extra argument has been added to <tt>string.dump()</tt>. If set to
  198. <tt>true</tt> or to a string which contains the character <tt>s</tt>,
  199. 'stripped' bytecode without debug information is generated. This speeds
  200. up later bytecode loading and reduces memory usage. See also the
  201. <a href="running.html#opt_b"><tt>-b</tt> command line option</a>.
  202. </p>
  203. <p>
  204. The generated bytecode is portable and can be loaded on any architecture
  205. that LuaJIT supports. However, the bytecode compatibility versions must
  206. match. Bytecode only stays compatible within a major+minor version
  207. (x.y.aaa &rarr; x.y.bbb), except for development branches. Foreign bytecode
  208. (e.g. from Lua 5.1) is incompatible and cannot be loaded.
  209. </p>
  210. <p>
  211. Note: <tt>LJ_GC64</tt> mode requires a different frame layout, which implies
  212. a different, incompatible bytecode format between 32 bit and 64 bit ports.
  213. This may be rectified in the future. In the meantime, use the <tt>W</tt>
  214. and </tt>X</tt> <a href="#load_mode">modes of the <tt>load*</tt> functions</a>
  215. for cross-compilation purposes.
  216. </p>
  217. <p>
  218. Due to VM hardening, bytecode is not deterministic. Add <tt>d</tt> to the
  219. mode string to dump it in a deterministic manner: identical source code
  220. always gives a byte-for-byte identical bytecode dump. This feature is
  221. mainly useful for reproducible builds.
  222. </p>
  223. <h3 id="table_new"><tt>table.new(narray, nhash)</tt> allocates a pre-sized table</h3>
  224. <p>
  225. An extra library function <tt>table.new()</tt> can be made available via
  226. <tt>require("table.new")</tt>. This creates a pre-sized table, just like
  227. the C API equivalent <tt>lua_createtable()</tt>. This is useful for big
  228. tables if the final table size is known and automatic table resizing is
  229. too expensive.
  230. </p>
  231. <h3 id="table_clear"><tt>table.clear(tab)</tt> clears a table</h3>
  232. <p>
  233. An extra library function <tt>table.clear()</tt> can be made available
  234. via <tt>require("table.clear")</tt>. This clears all keys and values
  235. from a table, but preserves the allocated array/hash sizes. This is
  236. useful when a table, which is linked from multiple places, needs to be
  237. cleared and/or when recycling a table for use by the same context. This
  238. avoids managing backlinks, saves an allocation and the overhead of
  239. incremental array/hash part growth.
  240. </p>
  241. <p>
  242. Please note, this function is meant for very specific situations. In most
  243. cases it's better to replace the (usually single) link with a new table
  244. and let the GC do its work.
  245. </p>
  246. <h3 id="math_random">Enhanced PRNG for <tt>math.random()</tt></h3>
  247. <p>
  248. LuaJIT uses a Tausworthe PRNG with period 2^223 to implement
  249. <tt>math.random()</tt> and <tt>math.randomseed()</tt>. The quality of
  250. the PRNG results is much superior compared to the standard Lua
  251. implementation, which uses the platform-specific ANSI <tt>rand()</tt>.
  252. </p>
  253. <p>
  254. The PRNG generates the same sequences from the same seeds on all
  255. platforms and makes use of all bits in the seed argument.
  256. <tt>math.random()</tt> without arguments generates 52 pseudo-random bits
  257. for every call. The result is uniformly distributed between 0.0 and 1.0.
  258. It's correctly scaled up and rounded for <tt>math.random(n&nbsp;[,m])</tt> to
  259. preserve uniformity.
  260. </p>
  261. <p>
  262. Call <tt>math.randomseed()</tt> without any arguments to seed it from
  263. system entropy.
  264. </p>
  265. <p>
  266. Important: Neither this nor any other PRNG based on the simplistic
  267. <tt>math.random()</tt> API is suitable for cryptographic use.
  268. </p>
  269. <h3 id="io"><tt>io.*</tt> functions handle 64&nbsp;bit file offsets</h3>
  270. <p>
  271. The file I/O functions in the standard <tt>io.*</tt> library handle
  272. 64&nbsp;bit file offsets. In particular, this means it's possible
  273. to open files larger than 2&nbsp;Gigabytes and to reposition or obtain
  274. the current file position for offsets beyond 2&nbsp;GB
  275. (<tt>fp:seek()</tt> method).
  276. </p>
  277. <h3 id="debug_meta"><tt>debug.*</tt> functions identify metamethods</h3>
  278. <p>
  279. <tt>debug.getinfo()</tt> and <tt>lua_getinfo()</tt> also return information
  280. about invoked metamethods. The <tt>namewhat</tt> field is set to
  281. <tt>"metamethod"</tt> and the <tt>name</tt> field has the name of
  282. the corresponding metamethod (e.g. <tt>"__index"</tt>).
  283. </p>
  284. <h2 id="resumable">Fully Resumable VM</h2>
  285. <p>
  286. The LuaJIT VM is fully resumable. This means you can yield from a
  287. coroutine even across contexts, where this would not possible with
  288. the standard Lua&nbsp;5.1 VM: e.g. you can yield across <tt>pcall()</tt>
  289. and <tt>xpcall()</tt>, across iterators and across metamethods.
  290. </p>
  291. <h2 id="lua52">Extensions from Lua 5.2</h2>
  292. <p>
  293. LuaJIT supports some language and library extensions from Lua&nbsp;5.2.
  294. Features that are unlikely to break existing code are unconditionally
  295. enabled:
  296. </p>
  297. <ul>
  298. <li><tt>goto</tt> and <tt>::labels::</tt>.</li>
  299. <li>Hex escapes <tt>'\x3F'</tt> and <tt>'\z'</tt> escape in strings.</li>
  300. <li><tt>load(string|reader [, chunkname [,mode [,env]]])</tt>.</li>
  301. <li><tt>loadstring()</tt> is an alias for <tt>load()</tt>.</li>
  302. <li><tt>loadfile(filename [,mode [,env]])</tt>.</li>
  303. <li><tt>math.log(x [,base])</tt>.</li>
  304. <li><tt>string.rep(s, n [,sep])</tt>.</li>
  305. <li><tt>string.format()</tt>: <tt>%q</tt> reversible.
  306. <tt>%s</tt> checks <tt>__tostring</tt>.
  307. <tt>%a</tt> and <tt>"%A</tt> added.</li>
  308. <li>String matching pattern <tt>%g</tt> added.</li>
  309. <li><tt>io.read("*L")</tt>.</li>
  310. <li><tt>io.lines()</tt> and <tt>file:lines()</tt> process
  311. <tt>io.read()</tt> options.</li>
  312. <li><tt>os.exit(status|true|false [,close])</tt>.</li>
  313. <li><tt>package.searchpath(name, path [, sep [, rep]])</tt>.</li>
  314. <li><tt>package.loadlib(name, "*")</tt>.</li>
  315. <li><tt>debug.getinfo()</tt> returns <tt>nparams</tt> and <tt>isvararg</tt>
  316. for option <tt>"u"</tt>.</li>
  317. <li><tt>debug.getlocal()</tt> accepts function instead of level.</li>
  318. <li><tt>debug.getlocal()</tt> and <tt>debug.setlocal()</tt> accept negative
  319. indexes for varargs.</li>
  320. <li><tt>debug.getupvalue()</tt> and <tt>debug.setupvalue()</tt> handle
  321. C&nbsp;functions.</li>
  322. <li><tt>debug.upvalueid()</tt> and <tt>debug.upvaluejoin()</tt>.</li>
  323. <li>Lua/C API extensions:
  324. <tt>lua_version()</tt>
  325. <tt>lua_upvalueid()</tt>
  326. <tt>lua_upvaluejoin()</tt>
  327. <tt>lua_loadx()</tt>
  328. <tt>lua_copy()</tt>
  329. <tt>lua_tonumberx()</tt>
  330. <tt>lua_tointegerx()</tt>
  331. <tt>luaL_fileresult()</tt>
  332. <tt>luaL_execresult()</tt>
  333. <tt>luaL_loadfilex()</tt>
  334. <tt>luaL_loadbufferx()</tt>
  335. <tt>luaL_traceback()</tt>
  336. <tt>luaL_setfuncs()</tt>
  337. <tt>luaL_pushmodule()</tt>
  338. <tt>luaL_newlibtable()</tt>
  339. <tt>luaL_newlib()</tt>
  340. <tt>luaL_testudata()</tt>
  341. <tt>luaL_setmetatable()</tt>
  342. </li>
  343. <li>Command line option <tt>-E</tt>.</li>
  344. <li>Command line checks <tt>__tostring</tt> for errors.</li>
  345. </ul>
  346. <p>
  347. Other features are only enabled, if LuaJIT is built with
  348. <tt>-DLUAJIT_ENABLE_LUA52COMPAT</tt>:
  349. </p>
  350. <ul>
  351. <li><tt>goto</tt> is a keyword and not a valid variable name anymore.</li>
  352. <li><tt>break</tt> can be placed anywhere. Empty statements (<tt>;;</tt>)
  353. are allowed.</li>
  354. <li><tt>__lt</tt>, <tt>__le</tt> are invoked for mixed types.</li>
  355. <li><tt>__len</tt> for tables. <tt>rawlen()</tt> library function.</li>
  356. <li><tt>pairs()</tt> and <tt>ipairs()</tt> check for <tt>__pairs</tt> and
  357. <tt>__ipairs</tt>.</li>
  358. <li><tt>coroutine.running()</tt> returns two results.</li>
  359. <li><tt>table.pack()</tt> and <tt>table.unpack()</tt>
  360. (same as <tt>unpack()</tt>).</li>
  361. <li><tt>io.write()</tt> and <tt>file:write()</tt> return file handle
  362. instead of <tt>true</tt>.</li>
  363. <li><tt>os.execute()</tt> and <tt>pipe:close()</tt> return detailed
  364. exit status.</li>
  365. <li><tt>debug.setmetatable()</tt> returns object.</li>
  366. <li><tt>debug.getuservalue()</tt> and <tt>debug.setuservalue()</tt>.</li>
  367. <li>Remove <tt>math.mod()</tt>, <tt>string.gfind()</tt>.</li>
  368. <li><tt>package.searchers</tt>.</li>
  369. <li><tt>module()</tt> returns the module table.</li>
  370. </ul>
  371. <p>
  372. Note: this provides only partial compatibility with Lua 5.2 at the
  373. language and Lua library level. LuaJIT is API+ABI-compatible with
  374. Lua&nbsp;5.1, which prevents implementing features that would otherwise
  375. break the Lua/C API and ABI (e.g. <tt>_ENV</tt>).
  376. </p>
  377. <h2 id="lua53">Extensions from Lua 5.3</h2>
  378. <p>
  379. LuaJIT supports some extensions from Lua&nbsp;5.3:
  380. <ul>
  381. <li>Unicode escape <tt>'\u{XX...}'</tt> embeds the UTF-8 encoding in string literals.</li>
  382. <li>The argument table <tt>arg</tt> can be read (and modified) by <tt>LUA_INIT</tt> and <tt>-e</tt> chunks.</li>
  383. <li><tt>io.read()</tt> and <tt>file:read()</tt> accept formats with or without a leading <tt>*</tt>.</li>
  384. <li><tt>assert()</tt> accepts any type of error object.</li>
  385. <li><tt>table.move(a1, f, e, t [,a2])</tt>.</li>
  386. <li><tt>coroutine.isyieldable()</tt>.</li>
  387. <li>Lua/C API extensions:
  388. <tt>lua_isyieldable()</tt>
  389. </li>
  390. </ul>
  391. <h2 id="exceptions">C++ Exception Interoperability</h2>
  392. <p>
  393. LuaJIT has built-in support for interoperating with C++&nbsp;exceptions.
  394. The available range of features depends on the target platform and
  395. the toolchain used to compile LuaJIT:
  396. </p>
  397. <table class="exc">
  398. <tr class="exchead">
  399. <td class="excplatform">Platform</td>
  400. <td class="exccompiler">Compiler</td>
  401. <td class="excinterop">Interoperability</td>
  402. </tr>
  403. <tr class="odd separate">
  404. <td class="excplatform">External frame unwinding</td>
  405. <td class="exccompiler">GCC, Clang, MSVC</td>
  406. <td class="excinterop"><b style="color: #00a000;">Full</b></td>
  407. </tr>
  408. <tr class="even">
  409. <td class="excplatform">Internal frame unwinding + DWARF2</td>
  410. <td class="exccompiler">GCC, Clang</td>
  411. <td class="excinterop"><b style="color: #c06000;">Limited</b></td>
  412. </tr>
  413. <tr class="odd">
  414. <td class="excplatform">Windows 64 bit</td>
  415. <td class="exccompiler">non-MSVC</td>
  416. <td class="excinterop"><b style="color: #c06000;">Limited</b></td>
  417. </tr>
  418. <tr class="even">
  419. <td class="excplatform">Other platforms</td>
  420. <td class="exccompiler">Other compilers</td>
  421. <td class="excinterop"><b style="color: #a00000;">No</b></td>
  422. </tr>
  423. </table>
  424. <p>
  425. <b style="color: #00a000;">Full interoperability</b> means:
  426. </p>
  427. <ul>
  428. <li>C++&nbsp;exceptions can be caught on the Lua side with <tt>pcall()</tt>,
  429. <tt>lua_pcall()</tt> etc.</li>
  430. <li>C++&nbsp;exceptions will be converted to the generic Lua error
  431. <tt>"C++&nbsp;exception"</tt>, unless you use the
  432. <a href="ext_c_api.html#mode_wrapcfunc">C&nbsp;call wrapper</a> feature.</li>
  433. <li>It's safe to throw C++&nbsp;exceptions across non-protected Lua frames
  434. on the C&nbsp;stack. The contents of the C++&nbsp;exception object
  435. pass through unmodified.</li>
  436. <li>Lua errors can be caught on the C++ side with <tt>catch(...)</tt>.
  437. The corresponding Lua error message can be retrieved from the Lua stack.</li>
  438. <li>Throwing Lua errors across C++ frames is safe. C++ destructors
  439. will be called.</li>
  440. </ul>
  441. <p>
  442. <b style="color: #c06000;">Limited interoperability</b> means:
  443. </p>
  444. <ul>
  445. <li>C++&nbsp;exceptions can be caught on the Lua side with <tt>pcall()</tt>,
  446. <tt>lua_pcall()</tt> etc.</li>
  447. <li>C++&nbsp;exceptions will be converted to the generic Lua error
  448. <tt>"C++&nbsp;exception"</tt>, unless you use the
  449. <a href="ext_c_api.html#mode_wrapcfunc">C&nbsp;call wrapper</a> feature.</li>
  450. <li>C++&nbsp;exceptions will be caught by non-protected Lua frames and
  451. are rethrown as a generic Lua error. The C++&nbsp;exception object will
  452. be destroyed.</li>
  453. <li>Lua errors <b>cannot</b> be caught on the C++ side.</li>
  454. <li>Throwing Lua errors across C++ frames will <b>not</b> call
  455. C++ destructors.</li>
  456. </ul>
  457. <p>
  458. <b style="color: #a00000;">No interoperability</b> means:
  459. </p>
  460. <ul>
  461. <li>It's <b>not</b> safe to throw C++&nbsp;exceptions across Lua frames.</li>
  462. <li>C++&nbsp;exceptions <b>cannot</b> be caught on the Lua side.</li>
  463. <li>Lua errors <b>cannot</b> be caught on the C++ side.</li>
  464. <li>Throwing Lua errors across C++ frames will <b>not</b> call
  465. C++ destructors.</li>
  466. </ul>
  467. <br class="flush">
  468. </div>
  469. <div id="foot">
  470. <hr class="hide">
  471. Copyright &copy; 2005-2025
  472. <span class="noprint">
  473. &middot;
  474. <a href="contact.html">Contact</a>
  475. </span>
  476. </div>
  477. </body>
  478. </html>