diff options
| -rw-r--r-- | doc/ext_ffi_semantics.html | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/ext_ffi_semantics.html b/doc/ext_ffi_semantics.html index 5ba82a1e..b56e57a1 100644 --- a/doc/ext_ffi_semantics.html +++ b/doc/ext_ffi_semantics.html | |||
| @@ -440,6 +440,19 @@ If you don't do this, the default Lua number → <tt>double</tt> | |||
| 440 | conversion rule applies. A vararg C function expecting an integer | 440 | conversion rule applies. A vararg C function expecting an integer |
| 441 | will see a garbled or uninitialized value. | 441 | will see a garbled or uninitialized value. |
| 442 | </p> | 442 | </p> |
| 443 | <p> | ||
| 444 | Note: this is the only place where creating a boxed scalar number type is | ||
| 445 | actually useful. <b>Never use <tt>ffi.new("int")</tt>, <tt>ffi.new("float")</tt> | ||
| 446 | etc. anywhere else!</b> | ||
| 447 | </p> | ||
| 448 | <p style="font-size: 8pt;"> | ||
| 449 | Ditto for <tt>ffi.cast()</tt>. Explicitly boxing scalars <b>does not</b> | ||
| 450 | improve performance or force <tt>int</tt> or <tt>float</tt> arithmetic! It | ||
| 451 | just adds costly boxing, unboxing and conversions steps. And it may lead | ||
| 452 | to surprise results, because | ||
| 453 | <a href="#cdata_arith">cdata arithmetic on scalar numbers</a> | ||
| 454 | is always performed on 64 bit integers. | ||
| 455 | </p> | ||
| 443 | 456 | ||
| 444 | <h2 id="init">Initializers</h2> | 457 | <h2 id="init">Initializers</h2> |
| 445 | <p> | 458 | <p> |
