IRC channel logs

2023-02-10.log

back to list of logs

<jfred>I have somehow done something horrific to my geiser session https://www.irccloud.com/pastebin/opbqGKMP/
<vv[m]>I got some weirdness like that before. I think I got use-modules is not a function or something
<jfred>Yeah, it wasn't recognizing any functions including the built-ins for some reason. It stopped happening after I fiddled a bit but I don't know what I did that fixed it
<flatwhatson>this can happen if you enter a module which doesn't exist
<flatwhatson>in the guile repl, entering eg. ",module foo" where there's no foo module defined, puts you into a completely empty environment
<flatwhatson>whereas (define-module (foo)) will actually import (guile) implicitly
<flatwhatson>this makes more sense if you think about guile as a multi-lingual environment :)
<vv[m]>any magic way to rename a function? Trying to see if I can port the magic of selfish-start to guile but not sure how that would work
<flatwhatson>vv[m]: what do you mean rename a function? functions are values, and identifiers (names) are bound to values
<vv[m]>ACTION sent a code block: https://libera.ems.host/_matrix/media/v3/download/libera.chat/6cf8075ab86532e025a6ec756e94bd0003f6b121
<flatwhatson>so if you have a function (define (bar) ...) you can (define foo bar) and call it with either (foo) or (bar)
<vv[m]>I think it's for the debugger so it doesn't have a name ^selfish-start always
<flatwhatson>oh, in that case probably using a macro is the cleanest option
<vv[m]>wonder if set-procedure-property! would work
<flatwhatson>yes, that's another option
<flatwhatson>(define (set-procedure-name! proc name) (set-procedure-properties! proc (acons 'name name (procedure-properties proc))))
<flatwhatson>(set-procedure-name! foo 'bar)
<vv[m]>yeah, seems to work
<vv[m]>I am not sure how to do the passing of the vals/keyword-vals either. hm. I find the documentation on this aspect a bit confusing
<vv[m]>would it be (define selfish-spawn #:allow-other-keys #:rest r) ?
<vv[m]> * would it be (define (selfish-spawn #:allow-other-keys #:rest r) ... ) ?
<flatwhatson>probably can just be (define (selfish-spawn constructor . args) ...) and let the constructor parse its own keyword args
<flatwhatson>keyword arguments aren't special in scheme, keywords are basically like symbols. the define* and lambda* forms just wrap the body in a let which finds them in the argument list and binds them
<flatwhatson>so (apply my-function-taking-keywords '(#:foo 1 #:bar "two")) works fine
<vv[m]>woot, I got it working
<vv[m]>ACTION sent a code block: https://libera.ems.host/_matrix/media/v3/download/libera.chat/040bda18697a813186ec9271b48049cb27a084ff
<vv[m]>goblins@(gib-gab-gob lib) [3]> (define* (^narcissus bcom self poopy #:key car bike) (format #t "~s ~s ~s ~s ~s" bcom self poopy car bike))
<vv[m]>goblins@(gib-gab-gob lib) [3]> (selfish-spawn ^narcissus "power" #:car "ford" #:bike "peugeot")
<vv[m]>#<procedure become (new-behavior #:optional return-val)> #<local-object ^narcissus> ("power" #:car "ford" #:bike "peugeot") #f #f$6 = #<local-object ^narcissus>
<vv[m]>hmm may need to unwrap the args one more time, seems they are in a list, but close.
<flatwhatson>vv[m]: it looks like you're renaming ^selfish-start, not what it returns
<flatwhatson>check the value of ^selfish-start in the repl to see if it's been renamed
<vv[m]>yeah it does seem to also change the original function as well, though, if you define multiple actors then they retain the original name they got. But yeah, messy. And also there's something not quite right with the final structure.
<vv[m]>I guess if ^selfish-start is simply defined inside, it is less 'scary'
<flatwhatson>the code you sent earlier, the last line of ^selfish-starts has: bcom (apply constructor ...
<flatwhatson>that bcom is a no-op, it's not called or returned
<vv[m]>oop yeah
<flatwhatson>vv[m]: maybe like this: https://paste.debian.net/1270229/
<vv[m]>ooh yeah that's cleaner
<vv[m]>Just had a missing self at the end but otherwise it works, I think!
<flatwhatson>cool :)
<flatwhatson>vv[m]: i missed passing bcom to the constructor, fixed version: https://paste.debian.net/1270230/
<flatwhatson>(er, still untested tho...)
<vv[m]>oh yeah I forgot that I also fixed that.
<vv[m]>lovely lovely! thanks for the help and it was cool to learn a bit further
<flatwhatson>happy to help, i'm learning too :)
<vv[m]>Perhaps I shall make a PR to add this since it is in the Racket version
<vv[m]>hooray, I was able to remove duplicated method definitions from an actor with (methods ...) using this ^_^
<jfred>flatwhatson: Oh! Right, I probably entered my module before evaluating its `define-module` expression. And I didn't know `define-module` did that, how neat. That explains it!
<jfred>vv[m]: Please do make a PR, I'd like to use it too! :D it's a handy thing to have around
<Zarutian_iPad>sneek, botsnack times ten!
<sneek>:)
<sneek>wb Zarutian_iPad!
<Zarutian_iPad>ACTION nerdsnipe sprayes with https://dev.to/spalladino/a-beginners-intro-to-coding-zero-knowledge-proofs-c56
<vv[m]><jfred> "vv: Please do make a PR, I'd..." <- I did! https://gitlab.com/spritely/guile-goblins/-/merge_requests/97
<vv[m]>it's annoying that the pipelines fail and make a big red unless you give them your CC info