Comments (6)
James, you need to get a twitter account ;-)
from xq-promise.
Weird how things work. I literally realized this myself last night and have begun work.
See my comment on #12
The pattern could be completely realized with closures. John from Marklogic eluded to this idea at the conference but it didn't click at the time.
Cheers!
from xq-promise.
declare function local:defer($work as function(*), $args as item()*) {
function () {
fn:apply($work, array { $args })
}
};
let $greet := function ($name) { 'Hello ' || $name }
let $promise := local:defer($greet, 'world')
return
$promise()
from xq-promise.
In Marklogic, you could implement fork immediately with a pure XQuery 3.1 implementation simply with your spawn-function. Then fork-join could be implemented with pure XQuery using the new fork function.
Cheers!
from xq-promise.
All tests pass except transform clause which requires the fix from Christian which he just merged yesterday. Checkout the xq-promise.xqm
file for the identical implementation with pure XQuery.
(Had to remove fork and only support fork-join) for now.
from xq-promise.
James; thanks for the new version, which really looks great, and which you implemented in hardly any time! I looked at the sources, and spontanteously, I have nothing to add that’s really noteworthy. Let’s stlil try, though…
It sounds a bit strict, but I think it could make sense to only accept arrays as function arguments (for p:invoke
and p:defer
). This it might reduce confusion if actual arrays are passed on as arguments:
p:defer(function($a) { $a instance of xs:integer }, 1), (: true :)
p:defer(function($a) { $a instance of array(*) }, [1]) (: false?... :)
(: ...or... :)
p:defer( function($a as array(*)) { (: ... :) }, [ 1,2 ] ), (: wrong :)
p:defer( function($a as array(*)) { (: ... :) }, [ [ 1,2 ] ] ) (: correct :)
from xq-promise.
Related Issues (16)
- Calling promise fails if worker takes more than one argument HOT 4
- fail should be provided a map with error information as well as arguments bound. HOT 3
- promise:fork HOT 24
- XML transformations cannot be parallelized HOT 1
- XPTY0004 issue with xq-promise 0.8.0 beta HOT 3
- Pass on arguments as array HOT 3
- Add support for EXPath packaging HOT 2
- Success callback called twice on failure
- When should pass non function items
- which promise specification is used as blue print, e.g. all() vs. when() HOT 12
- Support for updates HOT 5
- Rewriting FOR Clause HOT 4
- Promise Module → Async Module? HOT 3
- Update docs to leverage xquery:fork-join
- xq-promise Terminology vs. JavaScript/jQuery
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xq-promise.