2019-05-10 12:23:39 UTC - Olivier Tardieu: it is not possible to have nested function calls in composer https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557491019003800 ---- 2019-05-10 12:24:34 UTC - Olivier Tardieu: if the nested function (in this case resolve) is defined outside of the composed function (in this case dynamicInvoke) https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557491074004900 ---- 2019-05-10 12:24:51 UTC - Olivier Tardieu: you could however in this example define resolve inside of dynamicInvoke https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557491091005300 ---- 2019-05-10 12:25:01 UTC - Olivier Tardieu: this should work https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557491101005700 ---- 2019-05-10 23:15:32 UTC - Alexander Klimetschek: tried to move `function resolve()` inside `dynamicInvoke` but it fails with the same `resolve is not defined` error https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557530132006700 ---- 2019-05-10 23:15:55 UTC - Alexander Klimetschek: can I use imports (require)? https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557530155007200 ---- 2019-05-10 23:16:28 UTC - Alexander Klimetschek: would be nice to have a way to reuse code inside a composition other than invoking a completely separate action, especially for smaller things were a separate action is overkill https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557530188008000 ---- 2019-05-10 23:25:59 UTC - Alexander Klimetschek: uff, not even the `objectPath` argument in `dynamicInvoke()` works. the value passed in is a string literal. looks like it just takes the result value AST and hooks it in, ignoring the other function semantics :confused: https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557530759009300 ---- 2019-05-10 23:46:14 UTC - Olivier Tardieu: yes functions cannot capture their environment https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557531974010000 ---- 2019-05-10 23:46:14 UTC - Olivier Tardieu: <https://github.com/apache/incubator-openwhisk-composer/blob/master/docs/COMBINATORS.md#environment-capture-in-functions> https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557531974010200 ---- 2019-05-10 23:46:59 UTC - Olivier Tardieu: functions are only intended to provide for simple computations, actions should be used for more complex scenarios https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557532019011200 ---- 2019-05-10 23:49:04 UTC - Olivier Tardieu: imports of modules of the base image are possible https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557532144012400 ---- 2019-05-10 23:51:08 UTC - Olivier Tardieu: now including resolve in the right place should work: https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557532268013300 ---- 2019-05-10 23:52:34 UTC - Olivier Tardieu: ``` function dynamicInvoke(objectPath) { return composer.sequence( args => { function resolve(obj, path) { return require('path').split('.').reduce((o, key) => o && o[key], obj); } return { type: "action", name: resolve(args, objectPath), params: args } }, composer.dynamic() ); }``` https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557532354014500 ---- 2019-05-10 23:54:03 UTC - Olivier Tardieu: objectPath is another problem that can be solved using composer.literal or composer.let https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557532443015400 ---- 2019-05-10 23:57:19 UTC - Olivier Tardieu: ``` function dynamicInvoke(objectPath) { return composer.let('objectPath', objectPath, args => { function resolve(obj, path) { return require('path').split('.').reduce((o, key) => o && o[key], obj); } return { type: "action", name: resolve(args, objectPath), params: args } }, composer.dynamic() ); } ``` https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557532639016600 ---- 2019-05-10 23:59:19 UTC - Olivier Tardieu: let will capture the compile time value to make it available at runtime https://openwhisk-team.slack.com/archives/C7DJNS37W/p1557532759017500 ----