IRC channel logs

2021-08-13.log

back to list of logs

<daviid>vijaymarupudi: sorry, i am a bit on/off, but you don't need to 'guard' g-golf (goops) object instances, that's done by g-golf - you need to unref though, if your app consumes and releases thousands, millions or billions of ... and sort of never exit ... :) - unref automatically is (high) in wish list, i just never looked into this yet ...
<vijaymarupudi>daviid: I'm not sure what you mean by 'guard' in this case
<daviid>vijaymarupudi: you said earlier that g-golf gobjects need guardians... you don't
<vijaymarupudi>daviid: Ah I see! I meant that guardians would be useful to implement auto unref
<vijaymarupudi>daviid: I've found this chapter to be pretty fun to read, the guardian section implements an auto-free malloc (https://www.scheme.com/csug8/smgmt.html)
<daviid>vijaymarupudi: there is no way, that i am aware of, to know that a goops instances is being gc'ed, or is there? you don't wana auto-free malloc,oranything at that level, but call unref on the GObject instance, and let GLib/GObject u]handle the rest ... really vijaymarupudi you should scheme, using g-golf, and nothing else :)
<vijaymarupudi>daviid: Ah yes, I was referring to the auto-free malloc as a proof of concept for auto-unref.
<vijaymarupudi>daviid: There is a way to know when it's being GCed, if you add an after-gc-hook that calls a guardian that gobjects have been added to, it continuously returns gobjects that are ready to be unrefed.
<vijaymarupudi>I've been using this by make a manual wrapper for a widget I have a lot of in a GtkListBox, and it works pretty well!
<vijaymarupudi>making*
<vijaymarupudi>An important note is that the concept of floating refcounts are not very useful for this, so I've been calling the function to get rid of them
<vijaymarupudi>Referring to this: https://docs.gtk.org/gobject/method.Object.ref_sink.html
<vijaymarupudi>Here's a minimal example of this: https://paste.gnome.org/pjmfaofqu
<apteryx>is char-ready? safe to use assuming utf-8 characters? The doc suggests no, as utf-8 is a multi-byte (broadly speeking) encoding scheme
<roptat>is there a function that exists to return only the uniq elements of a list'
<chrislck>roptat: you'll need to roll your own... beware O(N^2)
<chrislck>if the order does not matter, check out 'delete-adjacenet-duplicates' in the guide
<apteryx>roptat: you could make the list a set?
<chrislck>if the order does not matter, check out 'delete-adjacent-duplicates' in the guide
<roptat>the order does matter
<roptat>mh... I get some weird errors... wrong number of arguments to <the first argument to the function>
<apteryx>roptat: perhaps delete-duplicates from srfi-1 ?
<roptat>(there is indeed a wrong number of arguments, but the function is not named properly in the error message)
<apteryx>I'm not even sure anymore 'read-char' is safe when the fdes was marked as read ready by 'select', as 'man 2 select' says "A file descriptor is considered ready if it is possible to perform a corresponding I/O operation (e.g., read(2), or a sufficiently small write(2)) without blocking.". In other words, I don't have any guarantee that a utf-8 multi-byte character can be read?
<apteryx>but then I guess in practice it 'usually works' because other programs output only 'valid' characters and don't pause in the middle of outputting a multi-byte character
<apteryx>I'm surprised Geiser doesn't seem to understand λ as 'lambda'
<daviid>vijaymarupudi: right, all GI bindings need to address 'floating references', and so does g-golf, and drop GObject instances ref-count to 0 so their mem is freed ... tx for the example
<apteryx>oh! annotated mcron output is finally showing good signs!
<apteryx>has the signature of the 'error' procedure changed?
<apteryx>nevermind
<apteryx>(no)
<apteryx>it was (rnrs base) that was changing it
<vijaymarupudi>daviid: You're welcome, hope it helps!
***kulernil is now known as kuler
<Izem>when I try (use-modules (ice-9 debug)) and (trace foo) I get an error, how are you supposed to trace in guile?
<leoprikler>Izem: call-with-trace maybe?
<Izem>is that in the same module?
<Izem>I'll try that
<Izem>I get: ;;; <unknown-location>: warning: possibly unbound variable `call-with-trace'
<lloda>looking for examples of a library using the compiler at run time
***chris2 is now known as Guest3666
***chris is now known as Guest3437
<dokma>How do I stop this from the repl side?
<dokma>guile -s <(echo '(use-modules (system repl server)) (run-server (make-tcp-server-socket #:port 51281))')
<dokma>I connect with: socat readline,history=/home/vlatko/.koinstructor_history TCP:127.0.0.1:51281
<dokma>I've already asked this and the best the guys came up with was: (kill (getpid) SIGINT)
<dokma>But just seems like using a sledgehammer to open a bottle.
<dokma>The repl module has stop-server-and-clients! but it doesn't do what the name advertises.
<dokma>I if do (stop-server-and-clients!) from the repl only the current client connections are closed. The server stays up and I can connect back in.
<leoprikler>dokma: You really ought to debug stop-server-and-clients! and find out why the server stays up.
***Guest3437 is now known as chrislck
<tohoyn>I have a large program whose behaviour gets erroneous with guile 2.2.7 when -O1 flag is used
<tohoyn>with guile 3.0.7 it works fine with -O1
<dokma>leoprikler: which debugger?
<leoprikler>dokma my personal favourite is inserting peeks, works like printf in C :)
<dokma>leoprikler: how do you insert peeks into a system module?
<leoprikler>do you want the cheap solution or the expensive one?
<leoprikler>the expensive one is checking out the source code, modifying and building everything
<leoprikler>the cheap one is putting a copy before it in GUILE_LOAD_PATH
<dokma>leoprikler: is there anything like gdb for guile?
<leoprikler>you can gdb guile moderately well and there's also a guile-internal debugger (which usually fires from the repl when an error is thrown)
<leoprikler>thirdly, you can call-with-trace if you just want to get a call trace
<canant>Hi guile team
<canant>Is it possible to use make-parameter without init value? Something like `(define param (make-parameter))`
<leoprikler>afaik no, but you can use *unspecified*, which is as good as "I don't know"
<dokma>leoprikler: call-with-trace might help me determine if a correct number of socket closes is executed
<canant>leoprikler: thanks, it seems there is no way
<leoprikler>for the record what would be the use case?
<canant>leoprikler: It's just for an experimental thing. I'm trying to understand the concept of the parameterize.
<maximed>dokma: Maybe use 'system-async-mark'
<maximed>(system-async-mark (lambda () (throw 'stop-the-server)) server-thread)
<maximed>canant: (fluid->parameter (make-unbound-fluid))
<canant>maximed: It's interesting. That I know make-parameterize is also using fluid under the hood, right?
<maximed>'parameters' are based on 'fluids' in Guile, yes
<maximed>'fluids' are a bit more general, e.g. there is no 'parameter' equivalent of 'fluid-ref*'
<maximed>From the Guile manual: ‘Parameter objects are implemented using fluids’
<canant>maximed: thanks for the details. I'll try this.
<dokma>leoprikler: am I botching this somehow? (call-with-trace stop-server-and-clients! #:instructions #t)
<leoprikler>call-with-trace takes a thunk
<dokma>I'm also wondering, even if I make the call properly, if anything will come back over the socket...
<dokma>leoprikler: what is a thunk
<leoprikler>a procedure with no arguments
<dokma>leoprikler: stop-server-and-clients! takes no arguments
<leoprikler>then idk
<dokma>is is a thunk then ?
<dokma>leoprikler: did I pass those named arguments correctly?
<dokma>I get: Unrecognized keyword: #:instructions
<dokma>Ohhh... it was #:instructions?
<dokma>Now the call works but I get no output because the socket is closed during the call...
<dokma>Damn
***apteryx_ is now known as apteryx
<mwette>(call-with-trace (lambda () stop-server-and-clients! #:instructions #t)) ?
<dokma>I think I might've figured out why stop-server-and-clients! doesn't stop everything. Apparently, (accept server-socket) is a blocking call and can be interrupted only by and interrupt.
<mwette>err (call-with-trace (lambda () (stop-server-and-clients! #:instructions
<mwette> #t)))
<dokma>mwette: I've managed to invoke call-with-trace correctly but it doesn't give me any output because during the execution of it the socket is closed.
<dokma>So, apparently, because the server is waiting for new connections in a blocking call throwing and interrupt IS the only way to stop the server.
<dokma>But that leaves us with a misleading name for stop-server-and-clients!
<maximed>dokma: Possibly irrelevant: see O_NONBLOCK
<dokma>maximed: already took a look
<dokma>the thing though is that repl is a system module
<dokma>The fact that stop-server-and-clients! doesn't do what it advertises should be seen as a bug.
<dsmith-work>Happy Friday, Guilers!!
<dokma>lol, my system uses ancient libguile...
<leoprikler>dokma pro tip when debugging server stuff: connect to the server and look at stdout
<avp>Hello guilers. I'm stuck with the Guile GDB support. I compiled the GDB 10.2 with '--with-guile' flag, but the documentation on how to use the Guile facilities in GDB is somewhat obscure.
<avp>This page https://www.gnu.org/software/guile/manual/html_node/GDB-Support.html says that this "pretty-printer" that I want should be loaded automatically. Yet my SCM values are still opaque.
<avp>I installed manually compiled GDB to '/usr/local' (this is the default path) on Ubuntu 20.04 LTS.
<leoprikler>avp what about the auto-load safe-path?
<avp>leoprikler: The docs says that I must add the directory where libguile is. I called gdb as follows: gdb -q -iex "set auto-load safe-path /usr/lib/x86_64-linux-gnu/*:/usr/share/gdb/*" guile
<avp>Is that right?
<leoprikler>when you're installing to /usr/local?
<avp>I already re-installed GDB to "/usr" -- now at least GDB loads debug symbols automatically.
<avp>Is there a way to force GDB to load Guile extension scripts? I'm trying to debug a Guile Scheme program that uses a Guile-enabled C library; my current guess is that GDB cannot determine what extension to load.