IRC channel logs

2022-06-01.log

back to list of logs

<stis>Tjaba guilers!
<rekado>I have a guile script (with shebang) that accesses (command-line).
<rekado>when I launch the script directly the (command-line) contains arguments to the script
<rekado>when I launch the script via /bin/sh -c the-script.scm arg1 arg2 arg3, however, the (command-line) value is empty
<rekado>is there a way to access the arguments in both situations?
<lampilelo>rekado: /bin/sh -c "the-script.scm arg1 arg2"
<lampilelo>arg1 and arg2 weren't the part of the -c argument, so they don't get passed further
<lampilelo>afaiu
<lloda>we should just remove master tbh
<rekado>lampilelo: thank you
<lechner>Hi, is it possible to load a module dynamically with use-modules? Can I catch when it was not found?
<amirouche>IIRC guix cli used to do that
<lechner>sorry, i meant "programmatically"
<amirouche>I am looking for the example code
<chrislck>lechner: (module-public-interface (resolve-module '(srfi srfi-1) #t #f))
<chrislck>lechner: (module-public-interface (resolve-module '(srfi srfi-bozo) #t #f))
<chrislck>(module-use! (module-public-interface (current-module)) (resolve-interface '(srfi srfi-1)))
<amirouche> https://git.savannah.gnu.org/cgit/guix.git/tree/guix.scm#n38
<amirouche>it is documented in the 'Module System Reflection' of the manual at https://www.gnu.org/software/guile/manual/html_node/Module-System-Reflection.html
<chrislck>(define (load-module mod)
<chrislck> (cond
<chrislck> ((module-public-interface (resolve-module mod))
<chrislck> (module-use! (module-public-interface (current-module)) (resolve-interface mod)))
<chrislck> (else (error "not a module: " mod))))
<chrislck>(load-module '(srfi srfi-1))
<chrislck>(load-module '(srfi srfi-bozo))
<lechner>amirouche chrislck: thanks!
<chrislck>this works until the srfi editors create a srfi-bozo
<lechner>chrislck: thanks!
<lechner>Hi, can the symbol part of a prefixed procedure call, as in prefix:parameter, be parametrized, i.e passed-in to the caller?
<amirouche>lechner: yes, and no. What are you trying to achieve?
<amirouche>you want to name or the prefix of the name of the called procedure?
<amirouche>by the way 'parameter' is its own idiom, that is: parameter ! argument
<amirouche>most of the time, if not all the time.
<amirouche>I never seen a parameter passed as procedure argument.
<lechner>amirouche: i'd like to reuse the code in 'identify' in the other five entry points. one good way seemed to parameterize the 'legacy:identify' and 'service:identify' http://ix.io/3Z8A
<lechner>sorry if that looks unpofessional. i'm a scheme newbie
<amirouche>I think what you look for a generics, but I do not have practical experience with it
<amirouche>lechner: do not say that please
<amirouche>lechner: are you familiar with single dispatch?
<lechner>i'm afraid not
<amirouche>well, the generics in scheme I know about, will dispatch based of the value of the arguments, it looks like oop, but there is less ceremony
<amirouche>the value and their type
<amirouche>so you can have a record <legacy-pam> and another <new-pam>, then in downstream code you can just call (manage-credential handle ...) and depending on the type of handle, it will call the intended procedure
<amirouche>I am not the best person to explain that with guile.
<amirouche>There is another approach that is even less sofisticated, that you can build with records, and instance of records that have procedures as fields
<amirouche>try that documentation https://www.gnu.org/software/guile/manual/html_node/Methods-and-Generic-Functions.html
<lechner>mwette: thanks again for the quick fix for linux-pam! now compile-ffi warns for pamc (in the compile phase) ;;; <unknown-location>: warning: possibly unbound variable `pamc_handle_t*' the typedef in C is somewhat unusual in that it includes the asterisk. is that something to worry about?
<lechner>amirouche: thanks!
<amirouche>lechner: an elder of the computing, and scheme world recommended me https://wiki.call-cc.org/eggref/5/fast-generic
<amirouche>recommended... to read.
<lechner>amirouche: thanks!
<lechner>Hi, should I use < or <? when comparing integers, please?
<lechner>Hi, can strings be used in a case expression? What does this error mean, please? warning: datum "service" cannot be meaningfully compared using `eqv?' in clause (("service") (begin (display "hello") (newline))) of case expression (case mode (("service") (begin (display "hello") (newline))) (else (ffi-pam-symbol-val (quote PAM_SYMBOL_ERR))))
<linas>guile on android !?
<linas>I'm working with a developer who seems to have compiled guile-2.2 for armv7 (android) ... but ...
<amirouche>yo :)
<linas>When calling guile from C++ for the first time, it crashes in the GC, trying to access bogus RAM not far from the guile mempool ...
<linas>searching for "guile on android" on duckduckgo gives only a 2018 blog entry on guix from civodul ...
<linas>hi amirouche!
<lechner>Hi, is there anything wrong with that 'case' expression, please? http://ix.io/3Z90
<lampilelo>lechner: yes, case can't compare strings
<lampilelo>you can use match from (ice-9 match) instead, e.g:
<lampilelo>(match str
<lampilelo> ("foo" 'foo)
<lampilelo> (_ 'not-foo))
<lechner>lampilelo: thanks! unfortunately, i have several strings
<lechner>can i use 'cond' ?
<lampilelo>you can define more patterns for match, but sure, you can use cond, you'd use string= in the clauses
<daviid>lechner: use (case (string->symbol mode) ((service) ...))
<lampilelo>clever
<lampilelo>a mode for something should probably be a symbol instead of a string anyway
<lechner>daviid: very clever indeed (and as a newbie, i'll remember) but i think i'll stick to cond for now
<lechner>what is the difference between string= and string=? please?
<lampilelo>string=? can compare more than 2 strings, string= can compare parts of 2 given strings
<lampilelo>(string= "foo" "oo" 1) => #t
<lechner>lampilelo: thanks!
<lechner>Hi, what is the 'name' argument to resolve-interface supposed to look like, please? None of my plain or quoted attempts is working.
<lechner>are working
<lampilelo>e.g. (resolve-interface '(srfi srfi-1))
<lampilelo>more complicated example: http://dpaste.com/2JNXAE62F.txt
<civodul>linas: that blog post is actually by roptat :-)
<civodul>Guix could be helpful to get Guile on Android i guess
<civodul>you could "guix pack guile", move the tarball to the Android device, and run it from there
<lampilelo>can you pack for a different architecture?
<linas>civodul: thank you! The developer seems comfortable compiling straight from source; I will ask him to create a pure, guile-only system ...
<civodul>lampilelo: yes, either through cross-compilation or native compilation (with transparent emulation or offloading)
<apteryx>lampilelo: I think I've done this in the past (run guile on android via a guix pack)
<apteryx>the hassle is you need root on the phone just to get started
<apteryx>(relocatable packs with PRoot was not working on android when I tried)
<apteryx>Another need for root is because on the extension media, it probably uses exfat or something that doesn't even support the executable bit, needed to execute your binary!
<lechner>lampilelo: thanks! i also use quasiquote, but where do i put the #:prefix, please?
<lechner>Hi, how may I prefix the symbols imported by this call with #:prefix, please? (resolve-interface (quasiquote (pam service (unquote (string->symbol subordinate)))))