IRC channel logs

2024-05-25.log

back to list of logs

<daviid>*forced to be in C ...
<cpli>i can't quite grasp at a solution that calls (poll-coop-repl-server server) reliably, but i don't want to resort to an arbitrary timer in the foreign event loop
<cpli>daviid let's assume i am, theoretically i think i could somehow poll the foreign descriptors and event sockets in my own event loop, but i know from experience that this foreign one is neat.
<cpli>if the docs are to be believed coop-server's entire point is to be embedded into programs with event loops (or single threaded applications) https://www.gnu.org/software/guile/manual/html_node/Cooperative-REPL-Servers.html
<cpli>polling arbitrarily makes me uncomfortable, can i not select on the clients at all daviid?
<daviid>cpli: sure, but probably not as neat as having the all app/lib written in scheme :) - fwiw https://github.com/wingo/fibers, which shows a pasteable example, and https://github.com/wingo/fibers/wiki/Manual
<cpli>even if i have my own event loop - using fibers or guile-a-sync3 - am i not just forced to call (poll-coop-repl-server server) repeatedly, every n ms?
<cpli>david: sure, let's use github:wingo/fibers. now: i only want to call (poll-coop-repl-server server) *when* there's something to evaluate. how could i do that?
<daviid>cpli: i'll let experts answer you, not my domain, but i wanted to suggest fibers and guile-a-sync3, and avoid C as much as possible - fwiw chickadee also has a coop-repl-server iirc, there is also the 8sync lib https://www.gnu.org/software/8sync/ ... so, it should be possible to avoid to reinvent and rewrite the wheel here, i think
<Kolev>ArneBab, I am having trouble using Wisp.
<Kolev>`no such language wisp`
<Kolev>ArneBab, I just want to convert my Lisp code to Wisp.
<daviid>cpli: not a maintainer, but i think fibers will land in core guile, sometime in the future - for a very flexible definition of future ...
<cpli>daviid: i don't know how useful "avoid c" is when in the next moment you bring up that chickadee also contains `coop-repl-server`, dynamically links a dozen c libraries, and calls `coop-repl-server` every frame (which i do too, in another application)
<cpli>also linking to more (in the case of bitrotten 8sync) guile async implementations, is not just unhelpful when there's a concrete problem that you yourself say you don't understand, it's outright inconsiderate
<cpli>i'm not rewriting the wheel (the coop-server), the wheel is there, just the axle doesn't fit
<daviid>cpli: it is always useful to avoid C, Fibers would be my first choice, the guile-a-sync3 (i mentionned the others for info ...) - there are quie a few fibers experts here, so if the answer to your specific quiz is not in the fibers manual, nor in any examples 'out there', just ask for help and be patient ...
<cpli>daviid, it was a race condition
<cpli>otherwise my approach works
<cpli>for some definition `(define (f x) (define (g x) (+ 3 x)) (g x))` is it possible to override `g` at call-site?
<rlb>cpli: if you mean "dynamic variable style", then no, not without some "opt in", i.e. say via https://www.gnu.org/software/guile/manual/html_node/Parameters.html Assuming I'm not missing the mark entirely.
<cpli>yeah, i expected as much. rlb
<cpli>as it stands (system repl server) calls `serve-client` on a separate thread: https://git.savannah.gnu.org/cgit/guile.git/tree/module/system/repl/server.scm#n133
<cpli>this means, that if you wish to keep your own list of all the ports belonging to the repl server, you can't "queue" the new client for the next event loop iteration port without racing.
<cpli>*the new "read-write client port"
<cpli>well, if you have an actual event loop, adding the file-descriptor would likely re-trigger dispatch
<cpli>let me see
<cpli>there's also some disconnect in the implementations: https://git.savannah.gnu.org/cgit/guile.git/tree/module/system/repl/server.scm#n141 calls `cancel-thread`, whereas https://git.savannah.gnu.org/cgit/guile.git/tree/module/system/repl/coop-server.scm#n178 simply calls `(close-fdes)`
<cpli>...
<cpli>is there some (define-syntax prepend-a- [...] ) which transforms (prepend-a- proc) into (a-proc)?
<tonyg>cpli: you'll want to reach for syntax-case and syntax->datum and datum->syntax, in conjunction with symbol->string, string-append and string->symbol
<tonyg>at least, that's how it has been traditionally. latterly systems like racket have sprouted convenience functions like format-id and format-symbol
<tonyg>perhaps there's a guile equivalent of those
<tonyg>format-id: https://docs.racket-lang.org/reference/syntax-util.html#%28part._.Creating_formatted_identifiers%29
<tonyg>making a guile equivalent in terms of the routines i mentioned above should be straightforward
<chrislck>sneek: botsnack
<sneek>:)
<sneek>wb chrislck :D
<chrislck>sneek: botsnack
<sneek>:)
<rlb>cpli: depending on what you're wanting, there's also use-modules (and define-module) #:prefix.