IRC channel logs

2020-10-10.log

back to list of logs

***catonano_ is now known as catonano
***sm2n_ is now known as sm2n
***rekado_ is now known as rekado
<rekado>hmm, I must be missing something. I put everything in a global guardian but sometimes it crashes and sometimes it doesn’t.
<rekado>according to gdb the crash happens when the library tries to copy the vector.
<leoprikler>maybe the library estimates a wrong size?
<stis>hey guilers!
<mwette>Ah, in the manual the copied string generated by string->pointer is freed when the pointer becomes unreachable. I think we need to change make-cstr-array to take an array of pointers and use (make-cstr-array/ptr (map string->pointer str-list))
<mwette>Well, (define spl (map string->pointer str-list)) (my-guardian spl) ...
<rekado>I’ve done that but it doesn’t seem to make a difference
<rekado>(I put everything in that global guardian: the pointers, the strings, the list of strings, the addresses, the bytevector itself)
<mwette>yikes
<rekado> https://paste.debian.net/1166611/
<mwette>Hmm.
<mwette>there are undocumented commands gc-enable and gc-disable, I just saw in the sources
<rekado>with gc-disable at the beginning of the file it does not crash, even when calling the C procedure 100 times
<rekado>it does crash when the file has just been modified and needs to be compiled
<rekado>but after auto-compilation: no crashes
<libfud>is there a generic string conversion function?
<libfud>like what's used by display?
<RhodiumToad>converting non-string values to strings, you mean?
<libfud>yes
<libfud>hey, I recognize you from #lua, you get around
<RhodiumToad>it looks like display is actually the primitive, and if you want a string representation of the result you wrap it using call-with-output-string
<libfud>ah, thanks
<RhodiumToad>using a string port like that is how (format #f ...) works for example
*RhodiumToad doesn't get around all that much, just has an interest in languages, especially embeddable ones
<libfud>I think it's actually with-output-to-string, but I could be doing this wrong
<RhodiumToad>with srfi-26 you can do:
<RhodiumToad>(define (obj->string obj) (call-with-output-string (cut display obj <>)))
<RhodiumToad>which is equivalent to
<RhodiumToad>(define (obj->string obj) (call-with-output-string (lambda (port) (display obj port))))
<libfud>ah
<libfud>almost all of my use of scheme has been in the context of the REPL and doing pretty simple things
<RhodiumToad>with-output-to-string is similar, but has to use a dynamic context to change the default output port
<RhodiumToad>whereas call-with-output-string just passes the new string port to the function
<libfud>is there an "assert" function or macro defined in any of the srfi or ice modules?
<RhodiumToad>I didn't find one when I looked, so I did my own
<RhodiumToad>(define (assert-fail e) (error (format #f "Assertion failed: ~A" e)))
<RhodiumToad>(define-syntax-rule (assert e) (unless e (assert-fail (quote e))))
<libfud>ah, I didn't know about unless either
<RhodiumToad>~S might be better
<leoprikler>there should be a ->string
<libfud> https://0paste.com/101937
<libfud>that's what I had made
<RhodiumToad>oh, yes, looks like object->string exists
<leoprikler>okay, it's called object->string
<libfud>so it's just that the price of object->string is probably significantly higher than <type>->string
<RhodiumToad>object->string uses write by default rather than display
<RhodiumToad>either way, object->string is just a C wrapper that does the call-with-output-string thing
<libfud>well, that makes sense
<RhodiumToad>(object->string obj display) is the same as (call-with-output-string (cut display obj <>)) in all respects other than being implemented directly in C
<libfud>is unless part of one of the scheme standards or is it specific to guile and some other implementations?
<RhodiumToad>I don't think it's in r5rs. not sure about later versions, but it's a trivial macro:
<RhodiumToad>(define-syntax-rule (unless test stmt stmt* ...)
<RhodiumToad> (if (not test) (begin stmt stmt* ...)))
<RhodiumToad>actually defined as that in ice-9/boot-9.scm
<apteryx>hello, what's the most idiomatic form to have some code execute no matter what (something called `finally` in other languages' execption handling?)
<apteryx>useful in cleanup code
<RhodiumToad>unfortunately continuations make that concept a bit tricky
<RhodiumToad>a given block of code might be exited more than once, do you want to run the cleanup each time?
<rekado>apteryx: dynamic-wind?
<RhodiumToad>dynamic-wind can and will execute the "outgoing" thunk multiple times if need be
<apteryx>rekado: that seems like it. I was looking up how call-with-temporary-directory cleans up in (guix utils) and that's what it's using
<apteryx>RhodiumToad: hmm, it wouldn't matter in my case even if it's ran multiple times
<apteryx>s/it's/it/
<apteryx>but thanks for the caution about that interesting bit (continuations meaning the same procedure might be exited multiple times)
<RhodiumToad>I don't personally approve of arbitrary continuations, but delimited continuations have some interesting uses
***terpri_ is now known as terpri
<afidegnum>i'm new in guile, what utility do i need to implement 2d graphics? i.e diagrams, graphs, interractions between them ?
<RhodiumToad>do you want to make a GUI app, or something that renders to output files?
<afidegnum>something that renders to output files, i guess, emacs could be a better bridge, I will be ok for a custom GUI too
<afidegnum>RhodiumToad: what do you think?
<RhodiumToad>so there's probably a bunch of ways depending on what you want to output and what tools and formats you prefer
<RhodiumToad>it's not hard to use sxml to output svg for example
<afidegnum>ok, in the nutshell, i wanted the built diagrams to output in json, which will be integrated into emacs, still reading on till i discover something handly
<stis>Amazing just compiling the python libs reveals bugs there as guile checks and warns for non bounded variables
<stis>love this feature of guile and I spen a lot of effort in copying that feature over to python-on-guile
<rekado>mwette: turns out it was my fault for misunderstanding the documentation of the library: it says that the vector must be NULL-terminated
<rekado>I assumed that it meant that the elements must be \0-terminated strings.
<rekado>but they actually mean that the last element must be a pointer with address 0
<rekado>after adding this extra element I cannot reproduce any crashes
<rekado>sorry for misleading you
<rekado>(and thanks again for your patience and help!)
<mwette>rekado: good result, then ; that is awesom; glad to see someone thrashing on the ffi-helper