IRC channel logs

2023-09-27.log

back to list of logs

<haugh>Do I understand correctly that SRFI-34's `guard' is always "unwinding"; i.e. it cannot access the continuation of the raise-exception?
<haugh>Uh, that is, cannot access it except for the case in which all clauses return #f
<haugh>I'm pretty sure this is true. My instinct is to go and write a continuable version of guard, but I've learned not to jump on what seem to be missing features without understanding why things are put together the way they are. Are continuable exceptions just not popular enough to warrant sugar? Is there something I'm missing?
<ieugen>hi, any guile users with emacs develpment experience ? I was wondering if there is or could be a scheme tree-sitter mode https://github.com/6cdh/tree-sitter-scheme/issues/9#issuecomment-1735486629
<ieugen>or a guile one at least
<abcdw>I've put together basic nREPL implementation in Guile: https://fosstodon.org/@abcdw/111136501925266684 It allows to connect to remote process over network, launch multiple evaluations simultaneously, interrupt evaluation, see output as it appears. Feedback is very welcome.
<minima>hi, how do i cast to boolean? anything simpler than `(if foo #t #f)'?
<RhodiumToad>usually you don't need to, since anything except #f is true
<minima>thanks RhodiumToad: yeah, here's some more context: `(remove (lambda (e) (eq? (valid? (car e)) (cadr e))) '((0 #t)(1 #f)))'
<minima>this fails removing `(0 #t)'
<RhodiumToad>presumably valid? is returning something true other than #t
<dsmith>There is also ->bool
<minima>yeah, sorry, i should have added
<RhodiumToad>yeah, ->bool should be ok
<minima>that `(valid? e)' returns `e' for valid items
<minima>oh super, that's what i needed then
<minima>thank you!! dsmith and RhodiumToad
<RhodiumToad>generally it's not usually done to compare booleans with eq? as far as I know
<minima>good to know, it seems to work fine in my case, it's just a quick and dirty script so i'll leave it as it is
<RhodiumToad>it does work to compare them in the sense that (eq? #t #t) is guaranteed to be true, etc.
<RhodiumToad>it's just not commonly appropriate
<minima>ah sorry, i thought you were talking of `->bool'
<minima>what's the form that i should use? `eqv?'?
<RhodiumToad>no, eq? is fine
<RhodiumToad>as I said it does work, it's just not usually done
<minima>oh ok
<lechner>Hi, what is the purpose of the "-s" command line option, please? Should it ever be used as part of a hashbang? Thanks!
<RhodiumToad>it's normally used as part of a hashbang in fact
<lechner>okay, so do i but i am encountering some strange behavior
<lechner>Do you use Guix?
<RhodiumToad>nope
<Arsen>lechner: it's to disambiguate. guile -foo.scm could be interpreted as flags, but not so if you call guile -s -foo.scm
<Arsen>see (guile)Command-line Options
<lechner>Arsen / yeah, i saw that. thanks!
<lechner>My hashbang says #!/bin/tool -f file -- /bin/guile -e main -s but my program is getting ("/bin/tool" "-f file -- /bin/guile -e" program-name)
<lechner>with program-name being the path to the script this is in
<RhodiumToad>hashbangs don't allow multiple args
<lechner>tool splits them. the issue is the mangling of the argument to -e
<lechner>tool receives three arguments!
<Arsen>see (guile)The Meta Switch
<RhodiumToad>what is your tool doing?
<lechner>loading a scheme file https://codeberg.org/lechner/preambled-exec
<RhodiumToad>what OS?
<lechner>right
<lechner>Guix
<lechner>i guess i am looking to confirm that it is likely an OS modification
<RhodiumToad>use a system call trace to look at the exact args being passed to each exec
<RhodiumToad>in particular I would not trust your env(1) binary not to be doing the wrong thing
<lechner>RhodiumToad / by 'env' you mean my own tool?
<lechner>i don't think i use env
<lechner>although i was inspired by it, if that's fair to say
<RhodiumToad>what you linked has a /usr/bin/env in the hashbang?
<lechner>RhodiumToad / okay, sorry. that gets replaced with an absolute path to the executable (like Nix) when Guix installs the program https://codeberg.org/lechner/guix-helper-bot/src/commit/b3fd0c5859ce4862392b3442368c9b8d762d6eac/guix.scm#L73-L74a
<lechner>thanks for the pointer to strace. i'm heading over to #strace
<ekaitz>hi, where's the string->utf8 procedure defined?
<RhodiumToad>libguile/;bytevectors.c
<RhodiumToad>s/;//
<old>ekaitz: string->bytevector then bytevector->string with utf-8 encoding
<RhodiumToad>huh?
<ekaitz>but what do I need to import to use it?
<old>ekaitz: ah sorry misread the question
<ekaitz>it was my fault explaining it
<RhodiumToad>(rnrs bytevectors)
<ekaitz>oh ok thanks!!
<dthompson>bytevector->string is in (ice-9 iconv)
<dthompson>also
<ekaitz>yeah, I found that one
<dthompson>different second arg
<ekaitz>string->utf8 has some examples in the docs but I think it doesn't say where it is defined
<RhodiumToad>it does
<RhodiumToad>more specifically, it's in the bytevectors chapter, which says (rnrs bytevectors) at the start
<old>right
<old>that's perhaps a problem of the doc IMO
<old>have to go up the section to get the use-modules thing for the example down the section
<old>I would not mind having a redundant use-modules for snippet in the manual
<ekaitz>oh! i just found it
<ekaitz>but it's like hidden in the text
<ekaitz>i would put it in an @example block
<ekaitz>to highlight the fact
<dsmith>Yeah, it would be sweet if all examples in the docs had the use-modules needed for the example..
<graywolf>Hi :) Would someone have an example of how to list a directory and define a variable for every file in it? E.g. for a directory with files foo and bar, I want to automatically create a module with (define foo "foo content") (define bar "bar content"). I am not even sure where to start :/
<dsmith>That sounds dangerous. You could have a file names that conflict with existing Scheme bindings.
<dsmith>How would you differentiate with Scheme variables and the directory variables?
<dsmith>Probably some kind of mapping like a hashtable would be better?
<graywolf>I... intended to not care about that. 1. it will be my directory, so somewhat controlled 2. it will be imported as ((files) #:prefix file/)
<graywolf>I mean, it would work, I just like the warnings about undefined variables and auto-completion
<old>graywolf: I can throw something after my phone call
<old>but to be clear you want something like
<old>./foo/bar
<old>(define foo "foo bar") ?
<old>or you want the content of the file?
<graywolf>For directory with two files, ./foo, and ./bar I want to (define foo "content of ./foo file) and (define bar "contetn of ./bar file)
<old>okay!
<graywolf>Hate to impose, but would be great help, thanks in advance! And no rush, dinner will arrive soon, so I will step afk for a bit anyway :)
<dsmith>Probably something with ftw and read-delimited, I'd imagine
<old> https://paste.sr.ht/~old/84f721acbcb6f244ec671233b734efef294e084b
<old>that ought to wor
<old>work
<RhodiumToad>probably need to export the vars
<dsmith>old, Probably need to either cd into directory-path or stat directory-path/file
<old>dsmith: true
<old>RhodiumToad: could be an option
<old> https://paste.sr.ht/~old/9f9c00d9f5e59815dab3b5924e739bf25f0743e7
<graywolf>old: Thanks a lot! :) It is easier than I assumed, I did not know about module-define!
<dsmith>Guile has several *at functions (statat for example) that take a "dir file port". How do you make one of those?
<dsmith> https://www.gnu.org/software/guile/manual/html_node/File-System.html#index-statat
<dsmith>Or is that just a regular file port that is in the same directory?
<minima>Hi, I've been banging my head against a module import problem, here's a MWE if someone is keen to have a look https://bpa.st/UHEQ
<minima>Basically, I'm trying to structure a small project of mine with an entry point file called my-project.scm and which contains the CLI logic
<minima>The program logic is in a separate library, my-project/main.scm
<minima>The error is `unexpected end of input while searching for: )'
<minima>I think it might have to do with the hashbang used
<dsmith>That means you have unbalanced parens
<dsmith>Well, pretty sure..
<minima>dsmith: hm yeah, let me triple-check that
<minima>thanks
<dsmith>scheme@(guile-user)> (read)
<dsmith>(foo
<dsmith>ice-9/boot-9.scm:1685:16: In procedure raise-exception:
<dsmith>#<unknown port>:3:1: unexpected end of input while searching for: )
<minima>hm... parentheses look ok to me as a matter of fact
<minima>The error changes if I edit the hashbang from `-e (@ (my-project) main) -s' to `-e (main) -s'
<minima>Which is not conclusive of anything but it'd make me think I need to escape the `@'?
<graywolf>I mean, there should be quotes around that
<graywolf>It is a shell
<graywolf>Also, can you have a space after #! in the shebang?
<graywolf>Never saw that before tbh...
<graywolf>Try -e '(@ (my-project) main)' -s
<minima>Right, good point, I've edited that away now
<graywolf>As the second line
<minima>ok
<minima>Nope... for the avoidance of doubt :) I'm going to repost it on bpa.st
<minima> https://bpa.st/UPKQ
<minima>Maybe it's bothered by the module in `my-project.scm' being called similarly to the module in `my-project/'?
<minima>A previous version was working by the way, where `my-project.scm' didn't have a `(define-module ...)' but just `(use-modules ...)'
<graywolf>minima: Out of curiosity, can you try to switch to different shebang? 1. line: #!/bin/sh 2. line: exec guile -e '(@ (my-project) main)' -s "$0" "$@"
<minima>sure thing, brb
<minima>Do I need a backslash at the end of line 1?
<graywolf>no
<minima>oh ok, something has changed... trying to understand if this error that I get now is upstream or downstream of the prev one
<minima>but hopefully this is progress!
<minima>brb
<minima>boom! it works!
<graywolf>noice :) Don't ask me what was wrong with your version, I have no idea :D
<minima>Going to repost the current version, then I'll have to understand why it works now! :)
<graywolf>I prefer this type of shebang, it is way more portable
<minima>graywolf: that's so helpful, thanks so much!
<minima>Current (working) version: https://bpa.st/4I4Q
<haugh>I'd like a version of (@ (ice-9 exceptions) guard) that provides bindings to both the `guard' continuation and the `raise-continuable' continuation, if applicable. Is there a reason why I should not want this? Is there something about this that's difficult or too opinionated to be flexible?'
<haugh>s/raise-continuable/raise-exception/
<minima>is it possible to `set!' a value defined in an imported module?
<minima>it doesn't seem so, or at least not with a simple `(set! some-var some-val)'
<haugh>minima, does module-set! do what you want?
<minima>hm it seems it should, thanks (i'm struggling with the syntax, but i should be able to find an example)
<minima>also, i might decide to move the original definition, which might make the problem go away
<haugh>minima, I can't replicate your problem. `set!' works fine for me on imported bindings. Can I see the module and the module user code?
<haugh>I see you already posted
<haugh>Why are you defining a module in an executable script? You can just define and execute main in my-project.scm
<haugh>also (format #t ...) does the same thing as (display (format #f ...))
<minima>haugh: i thought it might be convenient for testing? in case i wanted to test the CLI interface?
<minima>(oh! thanks re `format #t', that will save me some typing from now on! good to know, thanks!!)
<minima>re having a module in the script, i'm happy to go with whatever the most established approach is
<minima>do you have the feeling having a module in the script is less common?
<minima>the original hashbang was working just fine if i omitted the module, by the way