<davexunit>wingo: I tried using fibers but so far I've been unable to integrate it with my game loop. <davexunit>if I pass #:drain? #t to run-fibers, then I can't continue with the game loop <davexunit>if I don't pass it and let run-fibers spawn fibers and then return, those fibers don't do anything. <davexunit>maybe I need to implement a custom scheduler or something ***dje is now known as xdje
<pmikkelsen>Hello, how can i get unbuffered input from my keyboard in guile 2.0? <wingo>ACTION has an (ice-9 sandbox) <davexunit>care to share any details on how you accomplish the feat? <wingo>it has a timeout and will abort to a prompt if the timeout is exceeded. it exposes only a limited number of "safe" bindings to the code, which is evaluated in its own module. <wingo>there is also an allocation limit <wingo>and dynamic-wind isn't in that safe import module, so you can't prevent a cancellation <wingo>my only remaining question is about forged syntax objects <civodul>wingo: the sandboxed code has a separate the-root-module? <wingo>civodul: no, though that's not a bad idea; anyway it's a pure module that has a specific set of selected imports <wingo>and no procedures/syntax that can mutate those imports <wingo>i was thinking about it for guix <wingo>also here is an idea sketch: channels are great, guildhall as a simple channel sounds fine <wingo>to manage the channel and to add packages to that channel is the guildhall function <wingo>so "guix potluck init" to add the initial potluck.scm to your git repo <wingo>"guix potluck register" to register the repo with the service <wingo>"guix potluck notify" to tell the service to check for a new release <wingo>"guix potluck manage-channel" that is the actual web service <wingo>it has to evaluate code from users -- the potluck.scm <wingo>that's where the sandbox comes in. <civodul>and yes, Guix needs sandboxing at some point <civodul>i'm afraid about the many ways one could break out of the sandbox <civodul>like you could access (system foreign) via (guix packages) or something <wingo>right so my set of bindings doesn't include anything that can load a module or even any module-related values or procedures <wingo>once you start adding capabilities to the sandbox of course, that's when trouble comes in :) <wingo>but it's still a pretty big set of bindings (some 500 or so) <wingo>which is terrifying in its own right :P <wingo>still, things compose pretty well, it seems -- you can even have set-car! in the sandbox if no mutable list is among the capabilities granted to the sandbox <wingo>but even prompts work well i think <wingo>hmm, maybe not; that probably makes it too difficult to prevent syntax object forgery... <wingo>maybe we have to limit to syntax rules atm, which is fine i guess <ArneBab>paroneayea: for racket: racket scheme <ArneBab>wingo: re statprof: That’s strange, because before I could invoke (with-statprof ...) several times and have (statprof-accumulated-time) and (statprof-sample-count) outside that call <dsmith-work>wingo: Ooo. Sounds interesting. Maybe I could add an eval to the bot <add^_>Is there anyone working on getting guile to work on windows (does it already work perhaps?) <add^_>I'd like to try it out, but I'm currently working on windows, I'll be sure to get the new version on my laptop though <davexunit>wingo: do you think there's anyway that fibers could be integrated into an existing event loop? <dsmith-work>add^_: Yes, thare are people working on guile-on-Windows. Eli Zaretskii for one. <add^_>dsmith-work: Aha, Do you know if there is something that I could help with? ***profan_ is now known as profan
<dsmith-work>add^_: I *think* it's in pretty good shape, but I really don't know. Maybe check out the current open bugs? <wingo>scheme@(guile-user)> (eval-in-sandbox 'open-input-file) <wingo>$8 = (error unbound-variable #f "Unbound variable: ~S" (open-input-file) #f) <wingo>scheme@(guile-user)> (eval-in-sandbox '#(syntax-object open-input-file ((top)) (hygiene guile))) <wingo>$9 = (success #<procedure open-input-file (file #:key binary encoding guess-encoding)>) <davexunit>wingo: I'd like to spawn fibers but have my game loop keep chugging away. perhaps rather than having my game try to call run-fibers, I have a fiber that runs the game loop? <davexunit>because the scheduler wants to do its own thing, and my game wants to loop and poll for input and render and stuff <wingo>davexunit: yes that would work. if the game loop and the fibers are truly concurrent and long-lived and there's no obvious place to know when to switch, then running the game loop in a fiber sounds fine <wingo>otherwise i would suggest threads but i understand that's not what you want <wingo>like the web server backend does <davexunit>okay, I think this clears things up enough to press on. thanks. <davexunit>I don't even think I need to run the game loop as a fiber, but rather just call the game loop from within the run-fibers form <davexunit>ah the lambda you pass is run as a fiber? good to know. <wingo>but if the game loop will ever finish, that will make run-fibers finish when the game loop finishes <wingo>in that case yeah, run the game loop in run-fibers form and don't do #:drain? #t <davexunit>there's a prompt that can be aborted to when the game should end, and the game loop procedure will return at that point <wingo>i.e. keep #:drain at its default <wingo>your game loop will have to be suspendable for that to work well in a thread, fwiw <wingo>see that pitfalls section in the manual <wingo>"in a thread" == fibers and game loop in same thread <davexunit>well, it's not that things aren't suspendable, but the game loop needs some firm control over how time gets spent <davexunit>the game loop spins and renders at each iteration, but adds real time to an accumulator. once the accumulator has filled to a certain level, it calls the 'update' hook to update the game simulation. <wingo>by default fibers are preemptive <wingo>the question is just, will fibers be able to preempt your code <davexunit>nothing should generate un-resumable continuations, if that's what you mean <davexunit>I make plenty of calls to C functions, but they shouldn't ever be captured in the stack <wingo>sounds like it might work then <wingo>and if a tick happens and fibers is unable to preempt, then no big deal, it will try again next tick <wingo>ticks are every 10ms by default <davexunit>I have one more uncertainty, involving writing a 'sleep' replacement <wingo>if you decide that you would rather control yield points, you can call yield yourself <wingo>fibers implements "sleep" in its own way <davexunit>in the context of a game, I want to write a 'sleep' that sleeps for some amount of "game time", not real time. <davexunit>where "game time" is "how many times has the game loop ticked the simulation" <wingo>in that case if you double down on fibers (you might not want to) then i would have a fiber manage the current time and arrange to complete CML wait operations when the time advances <wingo>some other fiber would send messages to the timeout fiber to advance the time <davexunit>or is that a specialization of conditions? trying to be less ignorant here but the current state of my brain is what it is. <wingo>i think you would advance the time by messages on a channel yes <wingo>the timeouts themselves could be represented as condition variables i guess <wingo>or just thunks to call -- that's what (fibers internal) does with its timeout list <wingo>just maintains a PSQ from expiry time -> thunk <davexunit>hmm, don't quite follow that bit but maybe it will become clear when I spend more time with conditions. <wingo>and calls thunks when t > expiry. <wingo>priority search queue from (fibers psq) (impl by ijp) <wingo>a functional map that lets you manage something like that timeout set in expiry order <davexunit>I do exactly this with the coroutine system I made some years ago <add^_>Hm, it's been a while since I used the mailinglist, should I have the text in UTF-8 or ISO-8859-1 ? <add^_>I can see that no HTML is allowed <davexunit>but the priority queue isn't so fancy, it's taken from SICP mostly. <wingo>heya add^_, i think usually utf-8 is the thing <wingo>davexunit: if you think too much about time you will go absolutely crazy :) good luck! <davexunit>wingo: hehe I have gone a bit crazy thinking about this over the years already <davexunit>but this is looking good. I should be able to write a game with fibers without changing my game engine at all. <davexunit>my hope was that the engine would need no knowledge of such things so users could hook up 8sync or guile-async or whatever else <wingo>(if you use thunks for timeouts then have the thunks signal a condition variable; the utility is just reducing the coupling between the timeout fiber and the timeout-signalling mechanism) <davexunit>I will need some time to parse that one. gotta spend more time with fibers to have it all make sense. <davexunit>actually, one concern I am having now is that I won't have deterministic simulations without some tweaking. <davexunit>every tick of the simulation I need to be sure that I resume all the fibers that were waiting for the game time to reach this point <davexunit>otherwise repeated runs of the game may have different results because the scheduler will behave differently depending on how much real time has passed <reggggieee>hi, i have a quesion regarding generating a pdf document from scheme code. If I want control over the formatting and layout, is it best to go with straight sxml? or can i consider something like skribilo to produce xml, then format with an xml-fo? <amz3>reggggieee: it depends what kind of pdf you want to generate <amz3>AFAIK there is no way to generate pdf from sxml <amz3>skribilo doesn't use sxml per se, it does use a scheme syntax to describe the document <reggggieee>i'd like to design something a bit more custom formatted than 'documentation' - it's for like a resume/Cv <reggggieee>i've seen online that you can generate a pdf from xml with another formatting file called xsl-fo <reggggieee>both skribilo and sxml are able to convert to xml <amz3>if I were you I would use guile cairo to generate a pdf from sxml <reggggieee>so i guess i'm wondering if one way is more restricted than the other in terms of formatting capabilities. or if it doesn't matter because the xsl-fo can take care of the formatting/layout details <amz3>but prolly civodul knows better <amz3>reggggieee: cairo, is rather low level, you will need to layout everything yourself... but I am very interested in the subject <reggggieee>amz3: gotcha, yeah i don't mind having to do that <amz3>reggggieee: stay away from xsl, it's a dead language <reggggieee>o really, yeah i think i saw somewhere that it was going to be overtaken by a future iteration of css or something <amz3>reggggieee: are you familiar with flexbox layout? <amz3>basically it's powerful layout algorithm used in CSS <amz3>(maybe it's overkill for your immediate task) <amz3>there is at least two implementation one in javascript and one in Python <amz3>you might want to implement it so that you can describe your pdf in sxml and declare the layout in somekind of css scheme DSL <amz3>anyway, if you are stuck, don't hesitate to come back here :) <amz3>reggggieee: to get started you'd rather start mocking your resume/cv using only guile-cairo <amz3>getting into sxml->pdf can be overhelming <amz3>at last I found a good way to implement the cli interface in my project:) <daviid>reggggieee: you could also look into sxml to latex <amz3>my cli interface will be super awesome <amz3>the procedure-arguments proc is awesome <amz3>the problem with sxml->latex is that you still need to do some latex... <amz3>that's what skribillo does already <belak>How long should guile take to compile on modern consumer-grade hardware? I'm messing around trying to get Guile/Emacs running and it seems like it's hanging on BOOTSTRAP GUILEC ice-9/psyntax-pp.go <amz3>idk, but fwiw it's easier to get this done using guix... <davexunit>however if you build from the release tarball it should have a prebuilt bootstrap compiler that will cut time down significantly <belak>I'm on archlinux and installing the package using the aur <davexunit>well you should review what they are using as source <belak>So, I don't know if that's possible without modifying a bunch of stuff myself <belak>Ah, there's only "guile4emacs-git" <belak>So it doesn't have the included bootstrapped compiler, as it's from git <davexunit>so you are bootstrapping a compiler from scratch which will take many hours <belak>I've got plenty of other stuff to do <davexunit>guile builds itself without relying on an earlier version of itself <davexunit>which is actually a very good thing, but the tradeoff is build time <avoine>pmikkelsen asked a good question ealier: "Hello, how can i get unbuffered input from my keyboard in guile 2.0?" <avoine>would it make sense to have a guile binding to libinput? <amz3>doesn't guile-sdl2 support that? <wingo>hoo, fixing the syntax object forgery thing is hard <spk121>avoine: but, of course, this disable the action of ^C and friends <civodul>wingo: the problem is that syntax objects are regular vectors, right? <janneke>yay, mescc now supports a [very naive] malloc/realloc; almost ready to insert garbage collector <thomasd>janneke: from the readme, I understand that the bootstrapping path is (tbd) -> mescc -> (maybe tinyCC) -> gcc ? <thomasd>i'd like to ask more questions, unfortunately it's getting late here :) <janneke>thomasd: same here, save them for later ;-)