Code Monkey home page Code Monkey logo

Comments (6)

mgaerber avatar mgaerber commented on June 23, 2024

James, you need to get a twitter account ;-)

from xq-promise.

james-jw avatar james-jw commented on June 23, 2024

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.

james-jw avatar james-jw commented on June 23, 2024
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.

james-jw avatar james-jw commented on June 23, 2024

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.

james-jw avatar james-jw commented on June 23, 2024

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.

ChristianGruen avatar ChristianGruen commented on June 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.