aboutsummaryrefslogtreecommitdiff
path: root/docs/index.html
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2025-09-20 14:30:57 +0200
committerBenoit Germain <bnt.germain@gmail.com>2025-09-20 14:30:57 +0200
commitc52571736d852d2636bd285d19c613be5c706cff (patch)
tree50a1fc9b867197faa695c728008c8d0c7498b756 /docs/index.html
parentdc3de6ef8d4bb1a8ce7b2932515a0f6287ab1e76 (diff)
downloadlanes-c52571736d852d2636bd285d19c613be5c706cff.tar.gz
lanes-c52571736d852d2636bd285d19c613be5c706cff.tar.bz2
lanes-c52571736d852d2636bd285d19c613be5c706cff.zip
Improve table and userdata conversions
* add convert_fallback and convert_max_attempts to global settings * if no __lanesconvert is available, use convert_fallback (can be useful for externally provided full userdata with fixed metatables) * only try conversion on non-deep and non-clonable userdata * conversion can be applied recursively, up to convert_max_attempts times * plus all the relevant unit tests of course
Diffstat (limited to 'docs/index.html')
-rw-r--r--docs/index.html33
1 files changed, 30 insertions, 3 deletions
diff --git a/docs/index.html b/docs/index.html
index 2e74495..0d24d55 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -71,7 +71,7 @@
71 </p> 71 </p>
72 72
73 <p> 73 <p>
74 This document was revised on 03-Jul-25, and applies to version <tt>4.0.0</tt>. 74 This document was revised on 19-Sep-25, and applies to version <tt>4.0.0</tt>.
75 </p> 75 </p>
76 </font> 76 </font>
77 </center> 77 </center>
@@ -388,6 +388,30 @@
388 </tr> 388 </tr>
389 389
390 <tr valign=top> 390 <tr valign=top>
391 <td id="convert_fallback">
392 <code>.convert_fallback</code>
393 </td>
394 <td>
395 <tt>nil</tt>, <tt>lanes.null</tt> or <tt>'decay'</tt>
396 </td>
397 <td>
398 Same as <tt>__lanesconvert</tt> (see <a href="#other">Limitations on data passing</a>), but cannot be a function, because this would have to be transferred to all newly created lanes.
399 </td>
400 </tr>
401
402 <tr valign=top>
403 <td id="convert_max_attempts">
404 <code>.convert_max_attempts</code>
405 </td>
406 <td>
407 1 &ge; number &ge; 9
408 </td>
409 <td>
410 When a table or userdata conversion is performed with a function, it can happen recursively up to this number of attempts before triggering an error. Default is 1.
411 </td>
412 </tr>
413
414 <tr valign=top>
391 <td id="internal_allocator"> 415 <td id="internal_allocator">
392 <code>.internal_allocator</code> 416 <code>.internal_allocator</code>
393 </td> 417 </td>
@@ -1801,11 +1825,14 @@
1801 Using the same source table in multiple <a href="#lindas">linda</a> messages keeps no ties between the tables (this is the same reason why tables can't be used as slots). 1825 Using the same source table in multiple <a href="#lindas">linda</a> messages keeps no ties between the tables (this is the same reason why tables can't be used as slots).
1802 </li> 1826 </li>
1803 <li> 1827 <li>
1804 For tables and full userdata: before anything else, the metatable is searched for a <tt>__lanesconvert</tt> field. If found, the source object is converted as follows depending on <tt>__lanesconvert</tt>'s value: 1828 For tables and full userdata that are neither deep nor clonable: before anything else, a converter is searched for in the <tt>__lanesconvert</tt> field of its metatable.
1829 If there is no metatable, or no <tt>__lanesconvert</tt>, <a href="#convert_fallback"><tt>convert_fallback</tt></a> is used instead.
1830 The source object is then converted depending on the converter value:
1805 <ul> 1831 <ul>
1832 <li><tt>nil</tt>: The value is not converted. If it is not a clonable or deep userdata, the transfer will eventually fail with an error.</li>
1806 <li><tt>lanes.null</tt>: The value is converted to <tt>nil</tt>.</li> 1833 <li><tt>lanes.null</tt>: The value is converted to <tt>nil</tt>.</li>
1807 <li><tt>"decay"</tt>: The value is converted to a light userdata obtained from <tt>lua_topointer()</tt>.</li> 1834 <li><tt>"decay"</tt>: The value is converted to a light userdata obtained from <tt>lua_topointer()</tt>.</li>
1808 <li>A function: The function is called as <tt>o:__lanesconvert(string)</tt>, where the argument is either <tt>"keeper"</tt> or <tt>"regular"</tt>, depending on the type of destination. Its (single) return value is the result of the conversion.</li> 1835 <li>A function: The function is called as <tt>o:__lanesconvert(string)</tt>, where the argument is either <tt>"keeper"</tt> (sending data in a Linda) or <tt>"regular"</tt> (when creating or calling a Lane generator). Its first return value is the result of the conversion, the rest is ignored. Transfer is then attempted on the new value. If this also requires a conversion, it will be done, up to a depth of 3, after which an error will be raised.</li>
1809 <li>Any other value raises an error.</li> 1836 <li>Any other value raises an error.</li>
1810 </ul> 1837 </ul>
1811 </li> 1838 </li>