|
@@ -1763,8 +1763,9 @@ function(){
|
|
<div class="section">
|
|
<div class="section">
|
|
<h2 id="functiontype">Translating function types</h2>
|
|
<h2 id="functiontype">Translating function types</h2>
|
|
JavaScript functions work like Delphi's "reference to function", which
|
|
JavaScript functions work like Delphi's "reference to function", which
|
|
- means like closures. Normal functions and nested functions can simply be
|
|
|
|
- assigned to variables.
|
|
|
|
|
|
+ means like closures, capturing outer variables.
|
|
|
|
+ Assigning a normal function or nested function to a procedural variable is
|
|
|
|
+ translated to a simple assignment.
|
|
A Pascal method needs <b>this</b> to be the class or class instance.<br>
|
|
A Pascal method needs <b>this</b> to be the class or class instance.<br>
|
|
Note that <i>bind</i> cannot be used, because it does not support the <i>equal</i> operator.
|
|
Note that <i>bind</i> cannot be used, because it does not support the <i>equal</i> operator.
|
|
Instead a wrapper is created:
|
|
Instead a wrapper is created:
|
|
@@ -1842,6 +1843,9 @@ rtl = {
|
|
<ul>
|
|
<ul>
|
|
<li>You can assign a nested procedure to procedure variable.
|
|
<li>You can assign a nested procedure to procedure variable.
|
|
You don't need and you must not add the FPC "<i>is nested</i>" modifier.</li>
|
|
You don't need and you must not add the FPC "<i>is nested</i>" modifier.</li>
|
|
|
|
+ <li>A procedural typed declared as 'reference to' accepts in pas2js procedures,
|
|
|
|
+ local procedures and methods. Delphi only supports capturing procedures and methods.
|
|
|
|
+ FPC 3.0.4 does not support reference-to.</li>
|
|
</ul>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
|