IRC channel logs

2025-11-02.log

back to list of logs

<lechner>Hi, can Emacs find a function definition in the Guile sources? More specifically, where may I find the Guile function '*', please? The error message I'm seeing is In procedure *: Wrong type argument in position 1: #<pointer 0x1>
<ekaitz>lechner: how are you using *?
<kestrelwx>Do etags work with Guile? I haven't tried.
<identity>‘*’ only accepts numbers, which pointers are not, despite what some might make you think
<lechner>identity / okay, then I found a bug in Guile, I think
<ekaitz>I use universal ctags an i think it works in guile
<identity>lechner: could you show the code?
<ekaitz>lechner: also, * is not a guile function really... if you sear for '(define (*' you are not going to find it surely
<ekaitz>lechner: if you want to multiply a pointer you probably need pointer-address
<identity>in what situation would multiplying a pointer be a valid operation?
<ekaitz>identity: i'd say never
<lechner>Well, actually, I don't know. Here is what I'm doing in Guile-PAM: I pass a foreign pointer to a top-level Guile function in pam_conv(3), https://bpa.st/TDLA#1L50-L50
<ekaitz>ACTION has to go, but will check later if you didn't fix
<kestrelwx>Could `(ctype-size ...)` be really a pointer?
<identity>the only valid arithmetic operations on pointers are (+ ptr int) ⇒ ptr, (- ptr int) ⇒ ptr and (- ptr1 ptr2) ⇒ int
<identity>lechner: try asserting that num_msg and (ctype-size libpam:struct-pam_response) are not pointers
<lechner>kestrelwx / in which line, please?
<identity>lechner: there is only one use of ‘*’ in the code, no?
<lechner>yes, but it is expected to produce a scalar, not a pointer
<identity>but does it actually produce an integer or not?
<lechner>i think so ;;; ("(ctype-size libpam:struct-pam_response)" 16)
<lechner>my use case is confusing Guile, I think, because I make several round trips through FFI
<identity>and num_msg is also not a pointer, right?
<lechner>it is very much a pointer
<lechner>you are saying it should be an integer, per above?
<identity>then you get the error because you try to multiply a pointer by an integer
<kestrelwx>I thought the arguments were 0 counted.
<identity>(* 'one 'two) ;In procedure *: Wrong type argument in position 1: one
<lechner>identity / sorry! num_msg is an integer. the other variable you asked about earlier is a pointer.
<lechner>you folks are helpful! i kept looking at '* instead of *
<kestrelwx>identity: I guess in a list * would be the zeroth too.
<identity>lechner: just so we are on the same page, fill in the blanks in ‹num_msg : ___› and ‹(ctype-size libpam:struct-pam_response) : ___›, where the : means ‹is of type›, like ‹3 : Int› means ‹3 is of type Int(eger)›
<lechner>identity / they are both Int when called from greetd and agetty with login. I'm checking on Guile-Getty, but it takes a moment to reconfigure my test system. I owe you and kestrelwx a big thanks already. That * operator is the only place I multiply. More significantly, num_msg is always the integer 1 but the error shows <#pointer 0x1>. (The 1 is due to an early misinterpretation of the pam_conv(3) standard in Solaris as documented
<lechner>in the manual page)
<identity>lechner: if the error shows <#pointer 0x1>, then num_msg : Pointer, and you have to convert it to an integer first with (pointer-address num_msg)
<identity>when i asked you to assert earlier, i literally meant (assert (integer? num_msg))
<lechner>i have to pull guile and deploy for that. the error does not occur in my Guile test bed for Guile-PAM
<lechner>identity / the issue is that num_msg is an Int in most circumstances, which made me think it could be a bug in Guile
<lechner>and for some reason, guix pull takes about half an hour
<identity>not exactly the friendliest to fast iteration… you might want to try a different approach
<kestrelwx>Are you trying to pull just your channel?
<lechner>no, that's the problem. i have all my software in my custom channel but PAM is too rightly integrated with Guix System. It has to be part of my Guix fork until I figure out how to allow multiple channels when building Guix. Guix currently only allows the 'guix' channel when building itself
<lechner>i'd love to solve that problem
<identity>lechner: you could just copy the relevant modules to a different directory and then merge your changes back into the guix tree when you are done
<lechner>Guile-PAM's environment is isolated even though I'm not sure that's needed https://juix.org/guile-pam/#Runtime-Environment
<lechner>identity / in the error case, the types are reversed. you have to see it to believe it! i'll try to post picture
<lechner>i think libera is blocking the posts from my phone
<felixlechner> https://postimg.cc/75wDjXDp/9230a014
<dariqq>Does someone here know g-golf? I revisited an application from a couple of months ago and I get a goops error upon loading g-golf. Downgrading g-golf to 0.8.1 works.
<lechner>daviid may be the author / maintainer
<dariqq>hmm the diff between 0.8.1 and 0.8.2 is not that big. Reverting https://cgit.git.savannah.gnu.org/cgit/g-golf.git/commit/?id=ff8aa7eca6efb80b9a9c861f17df832621692f32 works as well.
<dariqq>i need to add that I do some unconvential things: I add g-golf to the %load-path and %load-compiled-path manually and it dies in some initialization. When guile knows of g-golf before then there is no issue
<lechner>Hi, what's a portable way to convert a signed integer into an SCM pointer, in Guile, please?
<identity>lechner: there is no portable way to convert integers to pointers, because pointers are more than just numerical values, they have provenance, and some systems strictly enforce that
<lechner>identity / well, i can do the two's complement off of (sizeof '*)
<sam113101>where can I learn scheme?
<humm>sam113101: https://schemers.org/ has a link “Docs” at the top
<identity>sam113101: a more concrete answer to this question depends on your previous experience as a programmer, or the lack thereof
<sam113101>I'm new to lisps but not new to programming. Actually I know a little bit of elisp but… I'd like to use a lisp as a more general programming language, not just to customize my text editor.
<identity>sam113101: i recommend The Little Schemer/The Seasoned Schemer, along with all the other Little books like The Reasoned Schemer (relational logic programming). additionally, Structure and Interpretation of Computer Programs (aka SICP aka Wizard Book) is a *really* good programming book, even if you already know programming pretty well, and it uses Scheme to teach more general program design concepts. some have recommended How to
<identity>Design Programs (HtDP) as a modern alternative to SICP that uses Racket instead, which is an almost-Scheme implementation that has roots in computer science education, but i have not read HtDP myself
<daviid>dariqq: having to reverse that patch doesn't make sense.it fixes a bug - what error do you get when using 0.8.2?
<daviid>dariqq: what 'unconventional things? how do you install g-golf? is it not in your distro?
<daviid>dariqq: is you app public, can I look at its code?
<dariqq>daviid: its not public (yet) and a bit too complicated for the bug (i embedded guile into a glib application and use g-golf to interact with it from the scheme side) and it just fails at "(use-modules (g-golf))". Give me a sec I have a backtrace from a simple example
<daviid>dariqq: tah's sounds totally crasy :-) GLib is a dynamic type system, you can't use g-golf 'from C', it will create a totally new dynamic GLib/GObject type instances ...
<daviid>dariqq: and anyway, why don't you write the app in scheme?
<dariqq>daviid: https://paste.debian.net/1404219
<dariqq>(this is unrelated to C and just trying to load g-golf from another location)
<daviid>dariqq: in guix, that won't work - in another distro you'd also to tell where the libg-golf lib is
<daviid>dariqq: I was commenting the error you get using 0.8.2, you can't use GLib from C, then load g-golf and expect it find the instances and classes ... total heresy
<dariqq>daviid: guix has the absolute path to libg-golf, i was just wondering why manually setting the load-paths messes something
<daviid>dariqq: in guix, you always have to do something as explained in its g-golf examples package, in emails as well, let me see if i can find one that explains ...
<dariqq>daviid: the bug with multiple glibs has been fixed, if thats the one you mean
<daviid>dariqq: yes, guix users needed to do this guix shell g-golf -D g-golf gtk [adw] --no-grafts; cd your/app-devel/path; ./my-app
<daviid>dariqq: https://lists.gnu.org/archive/html/guile-user/2025-04/msg00028.html
<daviid>dariqq: using g-golf from another location works fine, this what you'd do to test examples on a locally built not installed version: run the configure/make danse, then cd examples/libadwaita; ../../pre-inst-env ./adwaita-1-demo
<daviid>*cd examples/adw-1
<daviid>dariqq: also, before to use g-golf, you should import goops and call (duplicate-binding-handler '(merge-generics replace warn-override-core warn last)), then import g-golf
<daviid>but that won't solve the pasted bug, that is likely a guix related problem
<dariqq>daviid: I think I figured it out. Something fails to load and this is the error that someting is missing. Also adding gobject-introspection into the environment makes this work. I am not quite sure why, but that is something I can work with
<daviid>oh you were probably failing to load the libgirepository-1.0 then ... ok
<dariqq>but this is due to me trying weird things. The actual package will always pull in gobject-introspection
<dariqq>but that should be a patched to the absolute path but maybe it is not?
<daviid>right, g-golf depends on gobject-introspection, which among other toold also provide libgirepository-1.0 - in guix, not using the package, in a isolated env, means you have to redo all the package does ...
<daviid>dariqq: i can't help you when using guix, unless I can reproduce the problem here (debian testing)
<daviid>back to your 0.8.2 problem, so you understand why you shold not do what you're trying to do, now gvalue->scm calls g-object-find-class for the ginst pointer (of the goops proxy instance), and that maybe a subclass of the GType which defines the instance type. Now, you create an instance in C, load g-golf, which only dynamically oads subclasses, and you ask g-golf to find the class of an instance it did not create, so the subclass to
<daviid>which its belong does not exists ...
<daviid>dariqq: just forget using g-golf from C
<daviid>dariqq: why can't you write the app in scheme 'proper'?
<dariqq>daviid: Yeah I really need to look into that as is has been causing me a lot more pain than I like
<dariqq>thanks for your help
<daviid>dariqq: it just can not work - you clearly do not understand what a dynamic type system is: you load a C app, it did instantiate all GObject subtypes, avery class has its GType- now you import g-golf, it instantiate all GObject subclases, all have a diff GType value then the C ones ... it can't work, it will never work, just forget that route and write your app in scheme