IRC channel logs

2023-04-22.log

back to list of logs

<cow_2001>the web uri module is surprisingly easy to use
<dsmith>cow_2001, Blame that on wingo
<cow_2001>ACTION blames wingo around a bit with a large pointing finger
<cow_2001>how do you call those #:moo keyword symbols? why have two sets of symbols?
<RhodiumToad>#:moo is a keyword, 'moo is a symbol
<RhodiumToad>the main difference is that keywords evaluate to themselves, whereas symbols can be bound to values
<RhodiumToad>keywords are intended to be used as atomic tags in contexts where using a symbol might be confusing because you might think it's a variable
<cow_2001>can you give an example of a confusing expression?
<RhodiumToad>the obvious example is the use of keyword for argument lists
<RhodiumToad>(foo 1 2 3 #:someflag? #t)
<cow_2001>(foo 1 2 3 'someflag? #t)
<RhodiumToad>I believe the historical evolution of key/value args goes something like:
<RhodiumToad>first people used (foo 1 2 'moo x) because they could
<RhodiumToad>then someone had the bright idea of making symbols starting with : initialize to themselves rather than being unbound,
<RhodiumToad>so you could do (foo 1 2 :moo x)
<cow_2001>ACTION squints
<RhodiumToad>then that got split off into being a separate symbol type because it was cleaner
<ArneBab>flatwhatson: keep in mind that you’ll need quite a few hacks to keep websockets reliably connected — browsers to stuff like disconnect after too many seconds of inactivity.
<cow_2001>i want to run a guile script more than once at the same time. the first time should start a sort of server which the next ones would talk to. how do you do that? last time i used a pid file. checked for its existence and created if it wasn't there
<Arsen>simple - don't do that, have the user handle it
<Arsen>if all you want is mutual exclusion, you can use flocks
<cow_2001>it is a key binding to a script that makes sound. subsequent presses start more processes that add more stuff to the first process
<cow_2001>if i don't do the pid thing, the subsequent presses would start more sounds immediately, and that would be a cacophony
<cow_2001>i want a queue
<wklew>sounds like the server should be its own script that you run first
<cow_2001>no, it should be transparent and behind the scenes
<cow_2001>and right after the last item in the queue was handled, guile should exit
<cow_2001>cleaning whatever "i'm the first" files or whatever left around
<cow_2001>i wrote it in python once, but now i want to convert to guile
<cow_2001>and i wonder if there is a better way
<wklew>the pid file makes sense to me then
<cow_2001>it wouldn't really matter in this case, but in general, are there any race conditions for pid files? if the first process checks for existence of a pid file, then the second process checks for its existence, the first then decides it is the first, the second also decides it is the first, then the first makes a pid file, the second attempts to make a pid file and fails
<RhodiumToad>this is why we have O_EXCL, and flock
<cow_2001>hmmmmmm
<cow_2001>i would have to read on that.
<cow_2001>OH! i thought flocks are a kind of a concurrency thing, like……… what was it, the microthreads like thing
<cow_2001>but it is a short for file locks
<cow_2001>flocks sounds like a whimsical way of calling a bunch of microthreads, like a bunch of birds
<cow_2001>thank you
<old>ehh I though that procedure->pointer returns always the same thing
<old>apparently I was wrong
<RhodiumToad>same thing as what?
<RhodiumToad>you mean if you call it multiple times on the same procedure, or?
<old>yes
<old>Got bite hard with that with guile-ev and guile-parallel
<old>Need to keep a reference to the pointer, otherwise it can be reeused and now the C procedure in the event loop in libev could call something else
<RhodiumToad>right, procedure->pointer is allocating an object, effectively
<old>Is it coying the whole procedure?
<old>Do I need to keep reference to the pointer and the procedure
<RhodiumToad>no, it creates an object that encodes a call to the procedure
<RhodiumToad>that should, if I read this right, act as a reference to the procedure
<old>Ah okay!
<old>So it generate a small trampoline to the actual procedure while keeping a reference in it
<old>smart
<RhodiumToad>but you do need to keep the reference to the object returned by procedure->pointer for at least as long as it might possibly be called
<old>oh okay
<old>gotcha
<old>that's what I'm doing so fine by me
<dthompson>flatwhatson: hey thanks for the additional patch for guile-websocket. nice refactor! pushed to master.
<flatwhatson>dthompson: there's more in the pipeline, i think a port wrapper is needed and an accept api for servers
<cow_2001>turns out there's man 1 flock! and man 8 lslocks!
<Arsen>ah, yes - sorry, I forgot to elaborate on that
<cow_2001>you gave me a direction
<cow_2001>what happens if there is already an exclusive lock on a file?
<Arsen> A call to flock() may block if an incompatible lock is held by another process. To make a nonblocking re‐
<Arsen> quest, include LOCK_NB (by ORing) with any of the above operations.
<cow_2001>i want an atomic operation which will check a file for a lock, lock if there is none, and return true if it got the lock or false if it was already locked.
<cow_2001>i don't really understand the guile flock procedure
<cow_2001>oh okay
<cow_2001>there will be an error if i combine the nonblock with exclusive bit options
<cow_2001>okay, so now i need to do error catching cargoculting
<Arsen>that would be LOCK_EXCL|LOCK_NB
<cow_2001>okay, so now i'm trying to figure out how to handle the flock nonblock exception
<cow_2001>doesn't work because &non-continuable https://paste.debian.net/1278146/
<cow_2001>cargo culting
<mirai>what causes “Unknown # object: "#<"” and how can I quote a list that contains it
<jpoiret>mirai: guile reads #< somewhere. I'd wager it's a guix problem, we can talk about it there
<RhodiumToad>it's complaining because # is a magic character to (read), used as a prefix for special constructs; but no handler has been provided for #<
<RhodiumToad>what exactly do you need to quote?
<cow_2001>what am i doing wrong? i want the flock handle to return true if it got the lock and false if it did not https://paste.debian.net/1278157/
<RhodiumToad>use #:unwind? #t on the with-exception-handler
<RhodiumToad>by default, the continuation of an exception handler is the continuation of the throw of the exception, which is useful only for continuable exceptions
<RhodiumToad>setting the unwind flag makes the continuation of the handler be the continuation of the (with-exception-handler) form
<cow_2001>O_O thank you!
<cow_2001>RhodiumToad:
<cow_2001>almost 50 [redacted] years since the first pizza order over a speech synthesis computer https://www.youtube.com/watch?v=94d_h_t2QAA
<cow_2001>RhodiumToad: i haven't yet reached the continuation bit in the good book ~;~
<RhodiumToad>continuation just means "where computation goes next"
<RhodiumToad>so the continuation of a call to a procedure, for instance, is the state of the code at which it was called and what that does next
<RhodiumToad>it only gets complicated when you start thinking about what you can do with continuations that go somewhere else
<RhodiumToad>exceptions are one of the simpler cases of continuations, where you just want to abandon some part of the program and resume at an upper level of execution
<cow_2001>it's a fancy goto object, i've heard
<RhodiumToad>more complicated than that in the general case.
<cow_2001>RhodiumToad: i now have a procedure that ether returns a port of file with a lock this guile process owns, or #f when it doesn't own that lock. thank you!
<cow_2001>either
<cow_2001> https://paste.debian.net/1278165/
<RhodiumToad>cow_2001: you have a problem there
<RhodiumToad>cow_2001: file-port needs to be stored somewhere global, so that it doesn't get GC'd until you're done with it
<RhodiumToad>oh wait, you're returning it, missed that
<RhodiumToad>I would personally consider it better style to use (let)