Giter Site home page Giter Site logo

pointer access across await about ceu HOT 4 CLOSED

ceu-lang avatar ceu-lang commented on September 25, 2024
pointer access across await

from ceu.

Comments (4)

fsantanna avatar fsantanna commented on September 25, 2024

The pointer assignment/use is crossing a "par/or" rejoin, what is currently not allowed.
We may accept this program in the future, given that the assignment/rejoin/use occurs in the same reaction.
How difficult is to rewrite your code to get rid of the error?
I guess you wrote a simpler version and compiling it is not as simple as moving the "if c then..." to inside the "par/or".

from ceu.

Johnicholas avatar Johnicholas commented on September 25, 2024

The general pattern is: An organism is trying to acquire a pointer to something (by awaiting). The organism also wants to engage in an "idling" activity, which takes up as much time as necessary, but should be terminated when the organism can progress in its actual task.

Maybe this snippet conveys the (more complicated real task) more convincingly.

var Foo* ptr = null;
par/or do
_idle();
await FOREVER;
with
ptr = await generator;
end
_assert(ptr);
watching ptr do
_something();
end

I'll keep looking for a rewrite that doesn't involve crossing a par/or rejoin; it's probably a failure of imagination on my part.

from ceu.

fsantanna avatar fsantanna commented on September 25, 2024

Fair enough.

As a workaround, you can declare Foo as a "plain" pointer:

var Foo[] ptr = null;

(I also have a "TODO" with a similar pattern and workaround.)

from ceu.

fsantanna avatar fsantanna commented on September 25, 2024

Sorry, this is older than 1 year!

Using escape, you can assign safely to the pointer that syntactically crosses a par:

var u8&& ptr =
    par do
        //_idle();
        await FOREVER;
    with
        await 1s;
        escape null;
    end;
escape ptr == null;  // yields 1

from ceu.

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.