IRC channel logs

2017-03-22.log

back to list of logs

<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
<amz3>héllo
<amz3>I still get this error on my webserver http://dpaste.com/2VGA68N
<pmikkelsen>Hello, how can i get unbuffered input from my keyboard in guile 2.0?
<dsmith-work>{appropriate time} Greetings, Guilers
<daviid>hello folks!
<wingo>ACTION has an (ice-9 sandbox)
<davexunit>does it do what I think it does?
<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
<davexunit>interesting!
<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>let's call it "potluck" :)
<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
<civodul>wingo: sounds like a good idea!
<wingo>that's where the sandbox comes in.
<civodul>and yes, Guix needs sandboxing at some point
<civodul>very cool!
<civodul>i'm afraid about the many ways one could break out of the sandbox
<wingo>hoo, me too
<wingo>it's terrifying
<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 :)
<civodul>heh
<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>and define-syntax works
<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
<add^_>which has gnu/linux on it
<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?
<add^_>Sounds good in any case
<dsmith-work>add^_: I'd suggest inquiring on the mailing list(s)
***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?
<dsmith-work>sneek: bugs?
<sneek>Someone once said bugs is send reports to bug-guile@gnu.org, and see bug reports at http://bugs.gnu.org/guile
<dsmith-work>add^_: ^
<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)>)
<wingo>:P
<wingo>davexunit: yes
<wingo>what do you want to happen?
<add^_>dsmith-work: thanks
<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
<wingo>that's the same thing fwiw
<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
<davexunit>yeah that's exactly what I'm after
<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
<davexunit>yeah, makes sense.
<wingo>your game loop will have to be suspendable for that to work well in a thread, fwiw
<davexunit>hmmm
<wingo>see that pitfalls section in the manual
<davexunit>okay
<davexunit>perhaps this won't work
<wingo>"in a thread" == fibers and game loop in same thread
<wingo>what's not suspendable?
<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.
<davexunit>I'm not sure where to suspend, I guess.
<wingo>well
<wingo>by default fibers are preemptive
<wingo>so you don't have to decide
<davexunit>okay
<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>cool
<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
<davexunit>okay
<wingo>ticks are every 10ms by default
<wingo>of cpu time
<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
<wingo>so just call that
<davexunit>in the context of a game, I want to write a 'sleep' that sleeps for some amount of "game time", not real time.
<wingo>ah
<davexunit>where "game time" is "how many times has the game loop ticked the simulation"
<davexunit>it seems possible with conditions, maybe?
<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
<wingo>yeah
<davexunit>would the message sending be via a channel?
<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
<davexunit>okay
<davexunit>that makes good sense
<davexunit>thanks
<davexunit>I have a solid direction to head in now.
<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.
<davexunit>PSQ?
<wingo>priority search queue from (fibers psq) (impl by ijp)
<davexunit>ah yes
<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
<davexunit>and is a mutable queue.
<add^_>wingo: oki, thanks :-)
<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>okay
<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 isn't sxml
<amz3>skribilo doesn't use sxml per se, it does use a scheme syntax to describe the document
<CharlieBrown>Ne, skribilo estas ilo por skribado.
<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
<reggggieee>amz3: cool, i'll look into cairo
<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: have a look at http://wingolog.org/projects/guile-charting/ it use guile cairo
<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
<reggggieee>thnx, checking out the charting
<amz3>reggggieee: are you familiar with flexbox layout?
<reggggieee>not too familiar
<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> https://github.com/pybee/colosseum
<reggggieee>gotcha, will look into it as well
<reggggieee>sweet
<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 :)
<reggggieee>okies, thank you for the suggestions!
<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:)
<amz3>remi`bd: o/
<daviid>reggggieee: you could also look into sxml to latex
<reggggieee>daviid: ah, yeah true
<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
<amz3>fwiw
<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>belak: several hours is the norm.
<belak>Wow
<belak>That's crazy
<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
<davexunit>do you know what the build script is?
<belak>Ah, there's only "guile4emacs-git"
<belak>So it doesn't have the included bootstrapped compiler, as it's from git
<davexunit>yup
<belak> https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=guile4emacs-git
<davexunit>so you are bootstrapping a compiler from scratch which will take many hours
<belak>That's unfortunate
<belak>But I can wait
<belak>I've got plenty of other stuff to do
<davexunit>guile builds itself without relying on an earlier version of itself
<belak>:)
<davexunit>unlike most other compilers
<davexunit>which is actually a very good thing, but the tradeoff is build time
<davexunit> https://wingolog.org/archives/2016/01/11/the-half-strap-self-hosting-and-guile
<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?
<avoine>yeah
<wingo>hoo, fixing the syntax object forgery thing is hard
<spk121>avoine: you can get unbuffered input by setting the tty line discipline to raw http://paste.lisp.org/display/342115
<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 ?
<janneke>thomasd: yes, something like that
<thomasd>i'd like to ask more questions, unfortunately it's getting late here :)
<janneke>thomasd: same here, save them for later ;-)