Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database without server #142

Open
mbouaziz opened this issue Feb 12, 2014 · 2 comments
Open

Database without server #142

mbouaziz opened this issue Feb 12, 2014 · 2 comments

Comments

@mbouaziz
Copy link

This code

database string /foo = "bar";
print(/foo);

crashes:

/usr/local/lib/opa/stdlib/opabsl.opp/opabslNodeJsPackage.js:924
throw new (global.Error)("Your toplevel contains value which can't be synchron
      ^
Error: Your toplevel contains value which can't be synchronously computed
    at global.BslCps_topwait (/usr/local/lib/opa/stdlib/opabsl.opp/opabslNodeJsPackage.js:924:7)
    at /home/test/test2.js:116:40
    at Object.<anonymous> (/home/test/test2.js:116:203)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

whereas

database string /foo = "bar";
Server.start(Server.http, { function page() { <>{/foo}</> }, title: "Hi" });

works just fine!
Can't the database be used without a server?

@BourgerieQuentin
Copy link
Contributor

The error means that you can't write the /foo expression at toplevel because it's computation is asynchronously done.

This code should works:

database string /foo = "bar";
Schedule.push(function(){print(/foo)}));

@mbouaziz
Copy link
Author

Fair enough. You probably have good reasons to make this computation asynchronous. But then I guess it should be reported as an error at compile time.
Alternatively, Scheduler.push could be automatically inserted wherever needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants