Code Monkey home page Code Monkey logo

Comments (6)

mjp41 avatar mjp41 commented on June 30, 2024

I haven't checked the syntax against the current interpreter, but that should work.

To get the value you would do something like

  var r = Fib.fib(9);
  when (r) {
      // do something with r.v
     f(r.v)
  }

Now this will run the function f with the value that the parallel computation has calculated.

from verona.

libin049 avatar libin049 commented on June 30, 2024

I haven't checked the syntax against the current interpreter, but that should work.

To get the value you would do something like

  var r = Fib.fib(9);
  when (r) {
      // do something with r.v
     f(r.v)
  }

Now this will run the function f with the value that the parallel computation has calculated.

thanks mjp41. I want to concurrent execution Fib.fib(x - 1) and Fib.fib(x - 2), then get their result ,like this:

when () 
{
  p1 = Fib.fib(x - 1);
};
when () {
   p2 = Fib.fib(x - 2);
};
when (p1, p2) {
  var r = U64Obj.create(p1.v + p2.v);
  ...
};

I found it is hard to written.

from verona.

davidchisnall avatar davidchisnall commented on June 30, 2024

In the final syntax, this should end up looking something like:

p1 = when ()
{
  Fib.fib(x - 1);
};
p2 = when () {
   Fib.fib(x - 2);
};
when (p1, p2) {
  var r = U64(p1.v + p2.v);
  ...
};

We don't yet have an implementation that is at a state where we can write things like this yet. Hopefully soon...

from verona.

libin049 avatar libin049 commented on June 30, 2024

In the final syntax, this should end up looking something like:

p1 = when ()
{
  Fib.fib(x - 1);
};
p2 = when () {
   Fib.fib(x - 2);
};
when (p1, p2) {
  var r = U64(p1.v + p2.v);
  ...
};

We don't yet have an implementation that is at a state where we can write things like this yet. Hopefully soon...

thanks davidchisnall. I want to know, whether p1 and p2 types are promise[cown[U64Obj]&imm] above example? or p1 and p2 types are are cown[U64Obj]&imm ?

  • if type is promise[cown[U64Obj]&imm], can it be the args of when?
  • if type is cown, so cowns p1 and p2 Indicate asynchronous tasks here?

from verona.

mjp41 avatar mjp41 commented on June 30, 2024

So in the prototype, Promises are derived from cowns. This was to get things quickly working for a few examples. We have a few ideas of making them a first class concept. Either way we would intend them to be used in when.

from verona.

davidchisnall avatar davidchisnall commented on June 30, 2024

I want to know, whether p1 and p2 types are promise[cown[U64Obj]&imm] above example? or p1 and p2 types are are cown[U64Obj]&imm ?

Specifically on this, you definitely won't have a promise[cown[T]] for something like this (unless you explicitly want to return a cown[T] from a promise. It's still an open question whether promise[T] will be a subtype of cown[T], or whether promise[T] and cown[T] will be subtypes of some whenable[T] (and, if so, whether that's an explicit thing in the type system).

from verona.

Related Issues (20)

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.