IRC channel logs

2024-06-27.log

back to list of logs

<afm-victoria>Is this a bug? At the guile prompt:
<afm-victoria>(use-modules (ice-9 popen)
<afm-victoria>(list-index odd? '(2 4 5 6))
<afm-victoria>I get `ice-9/boot-9.scm:1685:16: In procedure raise-exception:
<afm-victoria>In procedure car: Wrong type argument in position 1 (expecting pair): #<procedure odd? (_)>`
<afm-victoria>But I don't get an error when I type
<afm-victoria>(use-modules (srfi srfi-1))
<afm-victoria>and then try: (list-index odd? '(2 4 5 6))
<cpli>afm-victoria: without replacing list-index with its replacement in srfi-1, guile's environment contains: https://git.savannah.gnu.org/cgit/guile.git/tree/module/ice-9/boot-9.scm#n1426
<cpli>i.e. (list-index '(a b c) 'b) => 1
<cpli>to my knowledge list-index isn't part of any rnrs standard.. so there wouldn't be any reason to expect any proper behavior
<cpli>afm-victoria: this weird simple list-index is loaded at startup, so it's not necessary to (use-modules (ice-9 popen)) either
<afm-victoria>Ah, this makes all the sense in the world! Thanks for enlightening me
<afm-victoria>Just learning Guile after a decade of Clojure. Feels so less *corporate*!
<cpli>schemes are pretty; guile is a little jack of all trades imo
<cpli>ACTION thinks it fits them ^^
<afm-victoria>I looked up list-index in the manual and didn't see any reference to (ice-9 boot-9)
<cpli>(ice-9 boot-9) is the startup module
<afm-victoria>Yeah, but the docs don't say that list-index is defined there too...
<afm-victoria>Anyhow, I really enjoy Guile. Guix is the draw but I am feeling drawn to use it for everyday stuff.
<cpli>boot-9 contains primitives such as apply, it's not something you expect to know unless hacking on guile itself
<afm-victoria>I have been playing with network sockets and wrote a little script that uses pipeline to run a sequence of shell commands. There is where I saw list-index. I got it to work with the srfi-1 import but wanted to understand the bug nonetheless
<afm-victoria>Chasing bugs is a great way to learn a new language!
<afm-victoria>And it really forced me to think about the example code--that's how I learn
<afm-victoria>cpli: really appreciate the perspective!
<daviid>afm-victoria: the manual procedure index is your friend, and looking at the list-index entry, you immediately see it is part of SRFI-1, and in guile manual, described in the section SRFI-1 Searching
<cpli>daviid, they're talking about the one that isn't document, the one that's loaded on startup by boot-9, not srfi-1
<cpli>afm-victoria: there's this long standing sentiment a few friends and i share with each other when we see we're upset over some bug: "confusion is good, would suck if there was nothing left to learn"
<afm-victoria>cpli: I actually like debugging--the world stops and I enter a place where solving the riddle is the key to happiness. Like playing a game but useful!
<afm-victoria>daviid: yeah, I looked list-index and invoked srfi-1 to get my code working but then was wondering why there was an *unlisted* list-index bound.
<daviid>ah ok, not sure why it's undocumented actually, nor does it have any string doc either, i mean the guile core version
<afm-victoria>daviid: the docs are pretty awesome but I think documenting *everything* is probably really daunting...
<cpli>is there a way to list all defined symbols in the current environment?
<afm-victoria>cpli: I spent a little time trying to see if there was a function that told me which module established the binding or all the bindings defined by a given module but failed...
<cpli>what function was there that would return a list of integers in a range? (f 1 3) => (1 2 3)
<cpli>iota
<cpli>how are you expected to make an array of structs for the c ffi without (@@ (system foreign) %write-c-struct) being public?
<lloda>i'd be in favor of deprecating-removing some of the (guile-user) things that are repeated in srfi-1 etc. The problem is when these are used in boot-9
<wingo>lloda: for example?
<graywolf>I wonder about #71262, do you it it has a chance of getting merged?
<old>cpli: I copied the code of %write-c-struct in my own module for that reason. Only problem might be license wise. Althought, it is quite trivial to write your own write-c-struct without looking at the code
<graywolf>Hm, I think there might be a bug in the docs. Using Guile Modules claims: The ‘#:select’, ‘#:prefix’, and ‘#:renamer’ clauses are optional. If all are omitted, the returned interface has no bindings.
<graywolf>But that is not what I observe: guile -c '(use-modules ((ice-9 ftw))) (pk scandir)' --> ;;; (#<procedure scandir (name #:optional select? entry<?)>)
<graywolf>Is this documentation bug or a code bug? What is the expected behavior?
<wingo>graywolf: documentation bug
<graywolf>wingo: Ok thanks, will send a patch.
<lloda>wingo: fold, list-index mentioned above
<wingo>lloda: fold is not in guile-user
<lloda>oh
<lloda>i remembered there being a fold with different arg order somewhere :-|
<civodul>R6!
<lloda>must be that
<lloda>this reminds me of this patch https://git.savannah.gnu.org/gitweb/?p=guile.git;a=commitdiff;h=a960d7869bc82bb56d5446ece01b8efff9b15fef
<lloda>the duplicated code
<lloda>is there a better way to do that?
<wingo>i usually end up doing (define-values (a b) (let () (define helper ...)... (define a ...) (define b ...) (values a b))
<wingo>i often define fold with different arg order as i often want multiple seeds, not multiple streams
<cpli>why does (system base target) use fluids for their %target-type, %target-endianness, and %target-word-size over parameters?
<graywolf>Hm, would anyone know how to use guile-cv to detect barcodes? (I am complete beginner)
<daviid>graywolf: it doesn't have that functionality
<cpli>why doesn't if have =>?
<cpli>i.e. (if 'a => (lambda (x) x) #f) => 'a
<haugh>cpli, there's and=>