IRC channel logs

2021-01-05.log

back to list of logs

<marusich>Is it easy to set breakpoints and walk through code in Guile like it is in some other languages? For example, in Java, using most modern IDEs, it is very easy and there are many simple guides describing how to do this. I have been using Emacs and Geiser for a while, but I have not yet really figured out what I should do to debug Guile programs step by step. I often wind up just using the undocumented "pk" or printing stuff myself, instead.
<marusich>I feel like I'm missing something that everyone else knows about.
<leoprikler>You can set breakpoints and traps using stuff from (system vm)
<leoprikler>For instance, if you want to trace procedure calls, you can use call-with-trace from (system vm trace)
***apteryx is now known as Guest5209
***apteryx_ is now known as apteryx
<fnstudio>hi, my little guile program grew to a point that i'd feel more comfortable if it could be split across multiple files
<fnstudio>does that mean that i should package different parts as modules?
<fnstudio>in other words, is "splitting across files" a synonym of "you need to create your own module"?
<maav>fnstudio: not necesarily, you could load the files directly... but any modularity facility is very useful in the long term
<maav>for guile you only need a matching file name for the module, e.g. (module name) must be placed on module/name.scm
<maav>and the forms define-module and use-modules
<fnstudio>maav: ok, cool, thanks; so i could technically split things up in different files and load them, but otherwise there's nothing wrong in using a module even if it's a small program
<fnstudio>excellent, thanks v much
<fnstudio>:)
<maav>you're welcome, and using modules is a good practice on all-sized programs (with the exception of launching scripts and throw-away code)
<maav>the module system is just an interface over loading manually the files and some cool enviroment modifications (as adding a prefix to the imported names)
<fnstudio>and when i write `(define-module (ice-9 popen))`
<fnstudio>ooops sorry, i meant `(define-module (my-module my-proc))`, i then need to make sure that's saved as file `my-proc.scm` in a `my-module` folder
<maav>exactly, the only bit missing at runtime is that you have to ensure that %load-path can access to it
<fnstudio>which seems to create a bit of coupling (between the module and the file path) but i suppose that's needed for a more general case
<fnstudio>*more general cases
<maav>yes, the coupling is intended, you always can create (my-module) too and don't use a subdirectory
<fnstudio>hm interesting
<fnstudio>vvv helpful, thanks maav
<maav>fnstudio: you're welcome :)
<leoprikler>you can decouple modules from filenames, but you're on your own if you do that
<leoprikler>for instance, the '(guile) module itself is merely defined in code. There's no (ice-9 boot-9) module.
<fnstudio>thanks leoprikler, good to know
<fnstudio>now... it seems i do have a little problem with %load-path, if i print that out from a repl, that doesn't seem to include my current dir
<fnstudio>is that expected?
<fnstudio>i think i found the answer
<fnstudio>GUILE_LOAD_PATH
<fnstudio>from here: https://www.gnu.org/software/guile/manual/html_node/Load-Paths.html
*fnstudio experimenting with that now
<fnstudio>ok, redefining the env variable seems to fix it; i wonder if there might be any downside in adding the current folder to my bashrc definition of GUILE_LOAD_PATH...
<renken_>I think it's either that or installing your modules in a standard path that already exists in %load-path/GUILE_LOAD_PATH
<fnstudio>renken_: cool, thanks for confirming, brill
<fnstudio>so, i now have a `my-module.scm` file that commences with `(define-module (my-module) #:export '(my-proc))`
<fnstudio>and a `main.scm` file that imports it, via `(use-modules (my-module))`
<fnstudio>guile seems to be complaining about `my-proc` not being defined though...
***renken_ is now known as renken
<fnstudio>ah, it seems it works now
<renken>I'm curious about what the problem was
<fnstudio>after replacing `#:export '(my-proc)` with `#:export (list my-proc)`
<fnstudio>let me confirm that, brb
<fnstudio>yeah, it seems it was that... using `'` instead of `list`
<fnstudio>this is very nice, i now have my small program nicely split up in different modules, thanks everyone for helping
<rekado>so… this is an old problem, but I still haven’t figured out how to avoid it: (web server)’s “run-server” can only be cancelled after hitting C-c twice
<rekado>is there a known recipe to get around this?
<maav>fnstudio: it is #:export (my-proc), not a quoted nor a list call, but a literal: (define-module (name) #:export (exported1 exported2))
<maav>with that definition you're exporting the name "list" too
<renken>how come this doesn't cause the evaluation of (my-proc)?
<maav>because it's a macro, not a normal evaluation
<fnstudio>maav: oh... i see... thanks for pointing that out
<fnstudio>maav: lol that my (buggy) version was still working!!
<fnstudio>maav: i can only imagine the headache that this could have caused in the future...
<fnstudio>tx :)
<maav>yes, some modules override procedures found elsewhere: e.g. (ice-9 format)
<maav>but it must be intentional, if you override list and also use a library that extends it, it will certainly cause issues
<fnstudio>yeah easy to imagine...
<renken>rekado: it could be because of the procedure call-with-sigint, check /usr/share/guile/3.0/web/server.scm
<renken>you can see that sigaction restores the C handler which is probably causing such a behavior
<lloda>imo the override of format is a mistake, the simpler proc should have a different name
<lloda>and i think that's the case for most overrides, really
<leoprikler>fnstudio: you normally don't want the current directory to be expanded into load-path
<leoprikler>what if you start guile in $HOME? Bad things happen
<leoprikler>the recommended way of setting GUILE_LOAD_PATH is through a build system, typically the GNU Build System
<renken>is adding $HOME/.share/guile to %load-path a common thing to do for local development, leoprikler?
<leoprikler>no, it's not
<leoprikler>The most common approach I've seen is to add a pre-inst-env.in script file to configure.
<leoprikler>then you can do ./pre-inst-env guile my-script.scm
<fnstudio>leoprikler: yeah, i thought that could be risky depending on the current working dir... but then i thought i was just being extra paranoid... i was not... :)
<leoprikler>since it's generated through autotools, you'll get absolute paths
<fnstudio>leoprikler: "GNU Build System" as in Makefile, as well?
<leoprikler>i.e. you can do /tmp/some-other-guile-project/pre-inst-env /tmp/my-guile-project/pre-inst-env guile something
<leoprikler>GNU Build System aka autotools means Autoconf, Automake etc.
<fnstudio>leoprikler: excellent, thanks!
<rekado>renken: thanks for the pointer!
<rekado>renken: it looks like registering *any* SIGINT handler with sigaction leads to this problem.
<chrislck>rekado: I'm glad I'm not the only one who can't terminate the webserver programmatically
<chrislck>see https://github.com/Gnucash/gnucash/pull/769
<rekado>interestingly, “guix publish” does not suffer from this problem.
<dsmith-work>Tuesday Greetings, Guilers
<dsmith-work>fnstudio: "." is not in the GUILE_LOAD_PATH for the same reasons "." is not in your PATH.
<fnstudio>dsmith-work: yeah, i see, thanks for reiterating it but yes, i see the point
***renken_ is now known as renken
<rekado>davexunit: found a little bug here: https://git.dthompson.us/guile-syntax-highlight.git/tree/syntax-highlight/scheme.scm#n31
<rekado>the variable %default-special-regexps should be %default-special-prefixes
<rekado>
<davexunit>rekado: I saw you mentioned a bug of mine but then my irc client lost connection.
<rekado>davexunit: https://logs.guix.gnu.org/guile/2021-01-05.log#181011
<davexunit>rekado: thanks
<davexunit>forgot about the new log location. haven't been paying attention to the channel topic.
<davexunit>rekado: that's an easy fix. pushed to master.
<rekado>thank you!
<davexunit>looks like refactoring gone wrong