I am trying to get a minimal app working on the browser–all it does is send text to the console. I got console.log working from outside Fibers (both the before and after promise calls work), but don’t understand why the code inside the promise doesn’t work, i.e., it doesn’t print anything.
That lambda needs to be the final expression in your program. When you do Scheme.load_main from JavaScript, you will receive this procedure as the return value. You can then use call_async to call it to launch your async program.
I have a new interesting issue RE: console-log in spawn-fiber in ttt.scm in the repo from the original post,
The ttt.scm file has the following structure:
Module imports
Foreign function definition for console-log
A bunch of code from (ice-9 q) b/c the module is not available for Hoot and I don’t know how to import my own modules yet
the Inbox queues code from Spritely that was shared in the call with minor mods, one of which is to call a function passed as its argument
A procedure called my-threads, called by Inbox where I use spawn-thread
Promise code
Note that my-threads spawns a number of fibers, one of which uses console-log. When looking at the browser console, you’ll see that there is an UncaughtInternalError: too much recursion corresponding to the fiber that uses console-log.
Any ideas on how to solve? No pressure–I understand this Hoot is bleeding edge software.
Interestingly enough, @afm-victoria, I suspect the problem you are experiencing is the same bug in the Hoot runtime I’ve been tracking down in our Goblins+Hoot porting effort which is also a stack overflow. I can’t be sure, having not run your code, but it’s my best guess.
The return type is specified as (ref null extern), but console.log returns undefined, which translates to no return value in Wasm. Try this instead and let me know if the problem goes away:
To reproduce, you can get the repo and run it with guix shell -m manifest, followed by make serve, and the go to the console in the browser to see the issue.
I have also encountered a stack overflow trying to get the car of a message received from a channel.
Do you folks have a guile-hoot-next available in a Guix channel somewhere? It would make sense for me to use the latest version if I am playing with bleeding edge stuff.
I think the unexpected continuation for n-valued result 0 error is happening because you have the console-log call as the last expression in a fiber but the fiber is expected to produce a return value. Try returning something, anything after the console-log call like #t or something.
Thanks for making this available. I was planning to chill until the next release but this means that I can keep on trying my stuff with the latest cut of the software.
This works fine when I use guile-hoot from the main Guix repo with no issues if I avoid console-log inside a Fibers thread but breaks catastrophically under guile-hoot-next. I assume that something changed in the compiler output that needs to be reflected in the code that loads the wasm module?
Hmmm I feel like I’ve seen this before but the root cause escapes me at the moment. Sounds like the web server is returning the wrong MIME type. Not sure why, though. You will need to update your reflect.js, reflect.wasm files if you haven’t done that yet, but I don’t see why forgetting to do so would cause this issue. I’ll reply again if I figure it out.
It turns out that display can print symbols but console-log doesn’t know what to do with them, so it got sick when I passed it a symbol. I don’t need console-log because display does what I want and is more capable, so I am going to rip console-log out.
I will go back to my tic-tac-toe stuff to see if I can get it working in the next couple of days.
Yup, you’re right that display is better! Most Scheme values are opaque from JavaScript’s point of view so console.log would mostly print out unhelpful information, anyway.
I feel like I should explain why you got that error because it could be of use to you in the future! It’s because your function definition looks like this:
This is saying that console-log accepts one argument which must be a string since the type is (ref string). If you want an FFI binding to be able to receive any Scheme value, use (ref eq) as the param type.