tonyg / syndicate

syn·di·cate: a language for interactive programs
http://syndicate-lang.org/
GNU Lesser General Public License v3.0
152 stars 11 forks source link

Box and client example not working as expected #38

Closed bobkocisko closed 4 years ago

bobkocisko commented 4 years ago

Hello! Thanks for this excellent language/framework! I'm just diving in to learn and am finding that none of the three box-and-client examples work as expected. I've tested the one verbatim from the dissertation document and it hangs forever with no output. I've also tested both that are in the examples directory and one returns immediately with #t and no other output and the other also hangs indefinitely with no output. Meanwhile I am able to successfully run the flip-flop example as well as the file system examples and they both work as expected. Is this a bug or am I missing something?

I'm running Racket 7.7 on Ubuntu 18.04.

howell commented 4 years ago

Some of the examples don't automatically write to stdout. The box-and-client ones, for example, produce log levels at the info level. You can see them by running them with

`> PLTSTDERR=info racket box-and-client.rkt

which for me, produces a whole bunch of stuff I don't care about such as

collapsible-value-bailout: arrow: can't prove single-return-value

as well as the box output messages like

client: learned that box's value is now 0
box: taking on new-value 1

I believe there's a way to change the log visibility levels in DrRacket as well, but can't remember off the top of my head.

The box-and-client in the actor/ examples subdirectory does have a termination condition, but the one in just examples currently just increments the box forever, so the behavior you're getting is just about expected.

Does running with logging enabled help?

bobkocisko commented 4 years ago

Thank you! Yes that does work. It turns out that there were two problems. For running the direct example from the dissertation I was trying to run my own file inside the interpreter via (open! "filename") instead of racket [file]. When I tried it as you suggested then all worked as expected. Also when I tried it in DrRacket it also worked fine there. But for the ones in the examples directory your suggestion with logging did the trick, and that makes total sense. Thanks for your patience with a newbie question!

bobkocisko commented 4 years ago

I should also ask: is there a way to use Syndicate in the REPL? This may be just another Racket newbie question but I can't seem to figure out how to interact with a database once it's been set up. Here's an example of the kind of thing that I'm getting when I try to use it in the REPL.

image

howell commented 4 years ago

Unfortunately, there's no support for REPL interactions like that in Syndicate at the moment.

I've been meaning to write some documentation for this, but essentially a #lang syndicate module defines a dataspace via top-level expressions that contain spawn forms. When you run the program, those spawns are collected, a dataspace is booted up, and at that point it is mostly "closed" to input from the REPL.

When/if that initial dataspace terminates, #lang syndicate prints a representation of the final "ground" assertions, which is the #f you've been seeing. To oversimplify, the ground assertions are those syndicate uses to communicate with the outside world, such as the implementation of various drivers.

Hope that made sense, please don't hesitate to ask any questions or for issues you may have!