IRC channel logs
2023-12-22.log
back to list of logs
<cow_2001>i don't get the (? predicate? ,a) match clause <apteryx>what's the most natural way to represent a timeval (C) value in Sheme? a pair? <apteryx>I'll split the second/microseconds component apart in time to call the lower level C procedure <apteryx>look like srfi 18 already worked a time datatype <apteryx>srfi 18 uses a pair for reprenting time in second and microseconds units <RavenJoad>This feels like something that is documented in the Guile manual, but I seem to be missing it. Is there an "rm -r dir" equivalent? <RavenJoad>Or do I need to write my own wrapper using delete-file, rmdir, ftw/file-system-fold? The manual has an example, "Here is an example showing how to display all the entries in a directory", but I am not sure how performant it is. <RavenJoad>Nevermind my question. I looked at how Guix implemented their delete-file-recursively, and is exactly what I was suggesting. <isaneran>(define (foo x) (assert (integer? x)) (+ x x)) (foo "hello") <isaneran>When running a program like this interactively and the assertion fails, I try to evaluate in the repl what x is, but there seems to be no way to retrieve it? <isaneran>with ,locals I just get a closure for the exception <isaneran>ah, wait if I do ,up and ,locals I can see x <isaneran>there was some case I tried where I couldn't see it the other day which was frustrating cuz if that happens many levels deep you wanna be able to retrieve it <isaneran>but I guess I either was mistaken or don't know a simple case to reproduce yet so nevermind! <isaneran>actually with (define (bar n) (assert (= n 2)) 42) it seems like guile has deleted n when running ,locals <chitochi>hi everyone! i am trying to get an expression to call a procedure when evaluated, so that for example in `(if x then else)`, the evaluation of x calls a procedure and evaluate to the return value of that procedure, is such a thing possible? :o <chitochi>(probably a bad idea, but i am still trying xD) <dsmith>chitochi, Why not just (if (x) then else) ? <chitochi>i just think i liked the idea of making it transparent, but the more i think about it the more it's not really a good idea <chitochi>the thing is that `x` come from a procedure, and so i can't know to what name it'll be bound, so i don't think a macro can handle that? <euouae>Hello can I print all exports of a module somehow? <apteryx>I see the scm_select implementation in Guile accepts both time values as long or double; why is this so? <apteryx>the underling select (2) accepts only long, as far as I can see <euouae>apteryx: probably because it converts fractional seconds to integral usec <euouae>it says usec has to be integral and sec can be either integral or fractional <apteryx>so the Guile select is more lenient on the input type than select itself, right? <euouae>yes, it just augments the interface with additional convenience features <euouae>generally that's all you can do with the kernel interface, add conveniences, you can't add real features on top <euouae>you can't select(2) on a sub-usec interval <apteryx>actually digging deeper the usec part of a timeval struct in C is an int64 <apteryx>I thought int64 was a float for a second <euouae>no kernel sources are more explicit about bit size <apteryx>I see: typesizes.h:67:#define __SUSECONDS64_T_TYPE __SQUAD_TYPE, and # define __SQUAD_TYPE __int64_t <euouae>Ther'es no reason to touch kernel sources <apteryx>and __suseconds64_t tv_usec; /* Microseconds. */ in struct_timeval.h <euouae>the user API is documented in POSIX or man pages <apteryx>yes, documented as suseconds_t tv_usec; /* microseconds */ <apteryx>I see. microseconds being capped at 999999 <apteryx>I think the complications stem from guile-udev using bare select (2) instead of scm_select in its C wrappers. <apteryx>I'll use scm_select and leave the existing abstractions do their job <apteryx>then I don't need to wrestle with timeval struct myself <euouae>I think using bare select is the right approach <euouae>you don't want cascading effects for changing one public wrapper <apteryx>using bare select means I must reimplement argument validation myself instead of reusing that of scm_select <euouae>in this case it could use scm_ version instead yeah <apteryx>a thunk is a procedure of zero argument, right? <apteryx>I want to use scm_catch, and it wants a thunk, which should capture things from the current scope <euouae>you mean, how do you define a scheme closure in C? <euouae>from C you typically want to make C functions available to Guile, not define Guile functions to make available to Guile <apteryx>replace the bare select (with its C error handling) by scm_select (and scm_catch for error handling) in the code linked earlier (udev-monitor-func.c:223) <apteryx>I want to use the C-usable Scheme procedures from libguile in C, e.g. scm_select, to hopefully simplify the problem <euouae>I wonder if "Exceptions and C" is what you want <apteryx>does select block when used without a timeout? <apteryx>any idea how I'd convert a C file descriptor (int) to a Scheme one? <apteryx>I guess scm_from_int, since it appears to be just a number? <euouae>7.2.2 Ports and File Descriptors <euouae>and yes to pass the file descriptor to scm_fdopen you need to convert to SCM from int <apteryx>select accept raw file descriptor (rather than ports), IIUC; so I don't need to use scm_fdopen, no? <apteryx>"with each member a port or file descriptor" <apteryx>another question: how do I create an empty Scheme list in C? <apteryx>I don't see scm_list_0 (it starts at 1) <euouae>it might be scm_list_1(SCM_UNDEFINED) <apteryx>ah, SCM_EOL, the scheme empty list object <apteryx>oh, gcc has a nested function extension for C <apteryx>that should make using scm_catch easier from C <apteryx>does clang implements this GNU C extension? <civodul>apteryx: Clang does not implemented nested functions <civodul>libguile doesn’t have nested functions though <euouae>I think apteryx wants to define a scheme closure (thunk) from C to pass to scm_catch <euouae>I couldn't figure out how to do that, it doesn't sound right to me because such a closure should be defined on the scheme side in my opinion <apteryx>civodul: does libgulie needs to have nested function? it's implemented by GCC <apteryx>ACTION wonders if SCM_DEFINE would work to define a nested function <apteryx>if it doesn't work I'll have to fallback to nested functions + scm_internal_catch <civodul>i think using nested functions in libguile at this point would hinder portability for little in return <apteryx>right, seems I can use scm_internal_catch and pass the args via a struct pointer, which removes the need <apteryx>I'm not working in libguile though, I'm working in guile-udev