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>now i need to stick this version into the guix package definition somehow <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 <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>when i run: guix shell -C guile -- guile -L . test-guile.scm <cow_2001>but test-body.scm has the line: (import (srfi 189)) <ArneBab>cow_2001: I *think* it should not —(import (srfi :189)) should. <ArneBab>(import (srfi 1)) just worked in the REPL <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 <cow_2001>keeping a changelog and news is a "pedantry" that makes everyone's lives easier <cow_2001>oh, it's not part of the guix guile distribution <ArneBab>Also note that there’s a pagebreak before new versions (shown in Emacs as ^L) <cow_2001>no, C-q is an emacs thing. you can just C-l and get ^L <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?