IRC channel logs

2024-06-07.log

back to list of logs

<Isaz>Hi, I have a beginner question on how to use closure similar to this example: (info "(guile) Serial Number") in order to create a procedure that stores a variable and also accepts an argument. Is it possible for someone to explain how to fix this example I have created? https://termbin.com/r969
<lloda>Isaz: i think you want to do (define iterative-add (let ((prev-num 0)) (lambda (num) (let ((result ...)) ... result)))). This isn't a generator, you use this as (iterative-add 3) => 3, (iterative-add 9) => 12 and so on
<lloda>if you think about it you'll see why your attempts fail
<lloda>the def i posted above isn't a generator but you can make one like (define (iterative-add x) (let ((prev-num x)) ...)) or something like that
<lloda>well idk what generator means here but hopefully it's clear
<cow_2001>BEHOLD! my pissant contributions! docstrings lifted directly from the srfi-189 document, plus some other bits and pieces: https://codeberg.org/kakafarm/guile-srfi-189/src/branch/make-it-compile
<cow_2001>adding to Cowan's and Zipheir's work
<cow_2001>now i need to stick this version into the guix package definition somehow
<chrislck>sneek: botsnack
<sneek>:)
<attila_lendvai>is there something deliberate in that QUIT simply throws 'quit instead of exiting in a more definitive way?
<old>attila_lendvai: The REPL and other mechanism can catach the 'quit exception and handle it. If you want to exit, call primitive-exit
<old>s/catach/catch
<attila_lendvai>i'm trying to make sense of what shepherd does with guit. it would be much cleaner if it did something more explicit than calling quit, that throws 'quit, which is then specially handled at a few exception handlers...
<haugh>I've noticed that when Guile intersects with Unix, configuration is often managed via global variables mapped to integers, e.g. SOCKET via PF_{INET{,6},UNIX} and SOCK_{STREAM,DGRAM,RAW,RDM}, etc. This hasn't caused a problem for me, I'm just wondering why map integers instead of using symbols? I suppose this would make sense to me if I had a C background.
<Isaz>lloda: thanks, your solution worked. :) I am almost understanding why my first attempt returns a procedure... Is what I wrote initially a set of nested lambda expressions? Maybe I am not understanding this example then: (info "(guile) Serial Number") because they also used the same syntax to create this let environment (why does it not also return a procedure? because "(one-arg-procedure)" returns a procedure where
<Isaz>"(zero-arg-procedure)" evaluates?)
<cow_2001>at this commit i have the WEIRDEST behaviour! https://codeberg.org/Zipheir/guile-srfi-189/commit/6e72cc50cc6b068de726f6e97b249a5af26d883c
<cow_2001>when i run: guix shell -C guile -- guile -L . test-guile.scm
<cow_2001>it works!
<cow_2001>but test-body.scm has the line: (import (srfi 189))
<cow_2001>and that should not work! D:<
<cow_2001>no?
<ArneBab>cow_2001: I *think* it should not —(import (srfi :189)) should.
<ArneBab>cow_2001: but it does …
<ArneBab>(import (srfi 1)) just worked in the REPL
<ArneBab>Changes in 3.0.8 (since 3.0.7):
<ArneBab>** Improve support for r7rs-style `(srfi N)' and r6rs-style `(srfi :N)
<ArneBab> module names (bugs.gnu.org/39601, bugs.gnu.org/40371)
<cow_2001>i've also sent it to the guile-user mailing list! :D
<ArneBab>found the part in NEWS
<cow_2001>oh that's in guile's NEWS
<cow_2001>keeping a changelog and news is a "pedantry" that makes everyone's lives easier
<ArneBab>yes
<cow_2001>where's the news on your system?
<ArneBab>in the Guile repository
<cow_2001>oh, it's not part of the guix guile distribution
<ArneBab>I don’t know. I did not check.
<cow_2001>no problem
<cow_2001>wow. they're thorough!
<cow_2001>thank you!
<ArneBab>Also note that there’s a pagebreak before new versions (shown in Emacs as ^L)
<cow_2001>/ C-q C-l
<cow_2001>in less
<cow_2001>oh, wait
<cow_2001>no, C-q is an emacs thing. you can just C-l and get ^L
<cow_2001>this is neat!
<cow_2001>is there any way of adding docstrings to syntaxes?
<cow_2001>(saw that "syntax" is how they call macros somewhere)
<freakingpenguin>Does #:use-module (foo) have any functional difference compared to (use-modules (foo)), assuming both are in a file with a define-module element?