IRC channel logs
2025-05-07.log
back to list of logs
<trannus_aran>GOOPS/CLOS-like question: is there any way to refer to slots of a class in the definition of the :initform of other slots? Say I have a playing card class with #:suit and #:rank constructors, but also a #:value accessor that relies on assoc-ing some global value alist with (card #:rank) <lechner>mwette / also, is it possible that #:include will not resolve absolute paths? <lechner>compile-ffi says: not found: "/gnu/store/l9467jv5sw5cc2a60nl6w96sxs8ls5m2-linux-libre-headers-5.15.49/include/linux/ptrace.h" but the file exists locally <mwette>you mean you have #include </gnu/store/.../ptrace.h> ? <lechner>I can add and then substitute #:inc-dirs but doing so with each individual header is more appropriate in Guix, which uses absolute paths whenever possible <lechner>i was also wondering if the ffi helper could export the symbol alist in addition to the accessor. it makes it possible to enumerate the symbols and, for example, construct reverse resolution (number->symbol) on subsets <lechner>although there i'm also happy having my own hardcoded lists. the Linux syscalls were a bit long but it's okay <mwette>I think that's a bug, in cpp.scm(find-incl-in-dirl). <lechner>do you want me to file a brief report on savannah? <lechner>ok, it would be easier if you had a commit for me since I cannot fork on savannah but i will try that later <lechner>thanks for the great customer service! <lechner>all those ifs recently made me switch to cond everywhere, btw <mwette>commit 5b493352715cd4a4a5004a0a3cc5c47375a0feff <lechner>mwette / although it isn't as useful as it sounded in #guix because Nyacc won't find the headers referenced in those absolute files unless that entire tree was patched (and the Linux kernel wasn't) <freakingpenguin>Is there an existing procedure to fold a list of elements but take a special action every X elements? e.g. concat a list of strings but add a newline every X string. <rlb>freakingpenguin: I'm not sure what's available srfi-wise -- in clj you could (apply str (flatten (interpose [\newline] (partition X lst)))) -- generality, at some cost. Not sure we have interpose and partition, but other ways to do it -- do you really need "any special action", or are you mostly just concerned about building strings? <rlb>I vaguely doubt there's any single function exactly like what you describe. <rlb>...but a (string-concatenate (fold/or-reduce ...)) should do it with a suitable fn, to build a result list, perhaps reverse!(ing) it at the end, etc. <freakingpenguin>rlb: So far, just building strings. I got something working using (fold foo string-list (iota string-list 1)), then checking if the 2nd argument is even, but that's not a solution I'm proud of. <freakingpenguin>Context is I'm generating latex code and need to splice some commands in every other latex fragment. <cow_2001>i don't know what to do with srfis not provided by guile. cond-expand is not aware of the packages i wrote packaging the srfi implementation examples from the official srfi account <cow_2001>if i provide an (srfi srfi-XXX) library somewhere in my path, shouldn't it be automatically added to the cond-expand list of features? <ArneBab>freakingpenguin: can’t you fold over both iota (on the length of your list) and the list? fold takes multiple list arguments. <rlb>cow_2001: cond-expand-provide, perhaps? <cow_2001>yes, but then you have to import a library that may or may not exist <cow_2001>you have to import library foo for cond-expand-provide to provide the feature flag foo before cond-expand can be used to make sure feature flag foo exists showing you can import library foo <dpk>cow_2001: the solution is to not use cond-expand features for this <cow_2001>dpk: i wrote a whole email for guix-devel and guile-devel for this <dpk>it’s like cond-expand, but the left-hand sides are checked at compile time, and expand into the right-hand sides <dpk>the difference being that the left-hand sides are real Scheme code (evaluated at phase 1) <dpk>cond-expand features were not very well-considered by the R7-small committee. they work well in Common Lisp which is designed for a live, essentially image-like environment where everything is incrementally compiled; they don’t work well in Scheme which is designed to support full static ahead-of-time compilation <dpk>yeah, see if Guile can work out a way to make the features idea work <cow_2001>which way should i go? i don't know how meta-cond works yet <cow_2001>do people send email to both mailing lists in a single email? that sounds a bit impolite <dpk>i mean, send that mail to guile-devel and see if anyone has any ideas, i guess <dpk>my own personal suggestion would be to mostly pretend cond-expand feature identifiers do not exist <dpk>and find alternative solutions <cow_2001>dpk: i will adapt the example implementation in my packages, then! thank you! <mccd>Heya, what is a way to keep the guile process alive? I'm noticing that one person does it with `( guile -q --listen=$socket -L .) >/dev/null 2>&1 </dev/zero` but that causes cpus to spin like crazy <lechner>mwette / Hi, what's a good way to get my system-specific CPP defines into compile-ffi, please? <lechner>Hi, is there way to include modules by file path rather than relative to the global search path? <lechner>or include code, rather. not sure the module declaration is still needed <freakingpenguin>ArneBab: Thanks for the suggestion, that's the route I'm going with. <ArneBab>freakingpenguin: glad to help. The main issue with that suggestion is that length is O(N), so that fold f i the-list (iota (length (the-list)) is at least 3xN (length + iota + fold). <ArneBab>freakingpenguin: an option to improve on that could be a generator (define gen (let ((i 0)) (lambda ()(define gen (let ((i 0)) (lambda () (set! i (1+ i)) i))) ;; ⇒ (gen) (gen) <ArneBab>freakingpenguin: that way you have a counter without setup-cost. <ArneBab>And you can call it in the function you fold over the data. <freakingpenguin>Thankfully in this context N<400ish and a majority of the runtime is due to API rate limiting, but good to know. <ArneBab>freakingpenguin: actually what I showed is just a function defined with internal state via let. The name generator may already be too much naming ☺ <ArneBab>You can generalize it by defining a function inside a function and returning it.