[Pas2js] sequencing function calls in pas2js
Mattias Gaertner
nc-gaertnma at netcologne.de
Sat Jun 9 01:03:51 CEST 2018
On Fri, 8 Jun 2018 16:47:23 -0500 (CDT)
warleyalex via Pas2js <pas2js at lists.freepascal.org> wrote:
>[...]
> ______________________________
> OBS: In JS world, we can use Function.prototype.bind to create a new
> function with a value passed to its first argument, like this
>
> .then(_doTask0.bind(null, '10000'))
> .then(_doTask1.bind(null, '5000'))
> .then(_doTask2.bind(null, '2000'))
> .then(_doTask3.bind(null, '0'));
> ______________________________
>
> Isn't there some simple way to do this?
Do you want a "bind" or do you want to create a call expression?
About "bind":
The "bind" needs two language features, that are specific to JS:
1. functions are objects
2. no type safety
The first would need pas2js support for typecasting a function to
TJSFunction.
The second needs an unsafe type cast from JSValue to whatever &then()
expects. Since you are missing any type safety anyway you can
simply use an asm block.
About creating a call expression:
Use a nested function or wait till anonymous methods are implemented.
Mattias
Mattias
More information about the Pas2js
mailing list