IRC channel logs

2020-08-22.log

back to list of logs

<lfam>I'm wondering, does Guile have a procedure that can be used to read a list in a random order? I'd like to randomize the order in which these URLs are accessed by Guix: https://git.savannah.gnu.org/cgit/guix.git/tree/guix/download.scm?h=v1.1.0#n63
<minerjoe>manumanumanu: thanks much. I know about those, was hoping for a more developed library, which I hadn't found yet. I'll give them a whirl.
<minerjoe>str1ngs: thanks!
***terpri_ is now known as terpri
<chrislck>lfam: list->vector, fisher-yates shuffle, vector->list?
<chrislck>all https://www.rosettacode.org/wiki/Knuth_shuffle#Scheme
***catonano_ is now known as catonano
<str1ngs>chrislck: is that a dance? or an algorithm? :P
<lfam>chrislck: Thank, I will check those out
***apteryx is now known as Guest87989
***apteryx_ is now known as apteryx
***apteryx is now known as Guest86213
<lisbeths>I am trying out this: http://www.gnu.org/software/guile-gtk/docs/guile-gtk/Introduction.html#Introduction and I get this: https://pastebin.com/raw/yssrrTCd
<lisbeths>I think I need to install the gtk-2.0 module from the command line but I cant find how to do that
<leoprikler>I think you need some guile-gnome module to fix your load path
<lisbeths>hmmmmmm do I need guix to do that or can I just do that with apt
<leoprikler>you probably already have the module, you just need the right use-modules clause
<lisbeths>so is my path messed up?
<bitwiz>lisbeths: apt install guile-gnome2-gtk I think
<leoprikler>not really, guile-gnome has this gimmick where you need to load the main module first and then can use the rest
<lisbeths>I tried installing that it still says no code for module (gtk-2.0 gtk)
<lisbeths>whats "the main module"
<bitwiz>Are you using Guile from Debian as well, or a version you installed yourself from source?
<lisbeths>I am using guile from ubuntu's snapshot of the debian repos for todays date on version 20.04
<lisbeths>I am not using debians repositories: ubuntu does not use those
<bitwiz>Ok, that sounds good (sorry - I assumed you were on Debian when you mentioned 'apt')
<lisbeths>My goal is to learn webassembly or webkit using gtk using scheme
<lisbeths>so I want to learn gtk for the first time using guile
<leoprikler>WebAssembly and Webkit sound like two very different beasts ;)
<lisbeths>then webassembly
<lisbeths>for now though I just wanna do gtk with guile
<leoprikler>for the record, where did apt install guile-gtk to?
<lisbeths>uh I do not know how to test for that
<lisbeths>i am willing to use guix package manager if that makes things easier
<leoprikler>the thing is, guix does not have guile-gtk, only guile-gnome if you're going for "old and finished"
<bitwiz>(guile gtk) looks to be really old and not updated for 13 years. (gnome gtk) from guile-gnome looks a lot more recent, although even that seems to be targetting Guile 2.2 and GTK 2.0
<leoprikler>if you want "new and experimental", then g-golf or guile-gi are probably what you want
<lisbeths>I would prefer old and finished for now
<leoprikler>in that case install guile-gnome from either apt or guix
<bitwiz>About finding the installed files: try 'find /usr/share/guile -name gtk.scm'
<leoprikler>For guile-gnome, you can find the docs at http://www.gnu.org/software/guile-gnome/docs/
<mauritslamers>Hi all, I have a system in which I use a global variable as a list of alists to keep a series of events. These alists have all possible properties already set with a value. Now in processing this event list I use an object property to keep track of a subset of these events. In a procedure I retrieve this subset and call another procedure to perform certain changes on these subset of alists. It turns out that the changes I perform on these ali
<mauritslamers>are not applies to the alists as I have them in the global variable. Somewhere on the way I lose the pointer / reference to the actual alists as they are in the event list. Could any of you shed some light on where that might be?
<bitwiz>How do you select the subset of events?
<bitwiz>It might be less confusing if you use a list of records instead of a list of alists
<mauritslamers>bitwiz: I understand, but that is not really possible at this moment as it would cause too much of an overhaul at this moment :)
<mauritslamers>I select the subset of events by adding them with append
<mauritslamers>(set! (objprop state-obj) (append (objprop state-ob) (list evt)))
<mauritslamers>so adding them one by one whenever I encounter them
<chrislck>isn't it better consing lists?
<mauritslamers>actually, that is what I am doing for these sublists, I use append for almost everything else as I don't want to change the order
<bitwiz>I'm not sure, but this looks very similar to the mess I got into with my own project. Start by drawing diagrams of cons cells and it should start making sense. I really recommend record types, then using filter to find the subset. It'll be less code, should work the way you expect, and might not even take much work
<mauritslamers>bitwiz: I understand your concern, and I will most surely have a deeper look at the record types. I am using alists as I am doing embedded guile in Lilypond, which uses alists exclusively as far as I know.
<bitwiz>Ah right, then it's not under your control
<mauritslamers>also, because of the transformation I need to do, I cannot use filter, as the structures of events can be nested and the properties I set can be in different nestings. The events are going one by one through a specific procedure. I gather the events based on a specific key having value true. After it turns false, I need to process the gathered events to change certain properties on those events
<nikita`>why am I banned from #guix ? I did type nothing in the last days. All I see in my log is a mass-ban of nicks
<bitwiz>Should your 'set!' be 'set-cdr!' ? How does 'objprop' work?
<nikita`>ok, nvm whatever it was i'm no longer banned
<mauritslamers>bitwiz: the objprop is an object property, as created by (make-object-property)
<mauritslamers>One of the reasons I was asking was that I wondered whether setting the value of an object property would cause a list copy instead of a pointer copy
<mauritslamers>nevertheless, it might indeed be that using records would make my life lots easier
<mauritslamers>my main programming language is JS actually, so I am more familiar with doing things mutable and keeping track of references as it is done in JS.
<mauritslamers>they seem to be available in guile 1.8.7 which is what Lilypond uses
<bitwiz>Yeah, the switch from procedural/mutable style to Scheme completely kicked my ass at first too (only just getting out of that now)
<bitwiz>Are you expecting (set! (objprop ...) new-val) to set the property itself?
<mauritslamers>and record types seem to be a nice way to document things
<mauritslamers>bitwiz:
<mauritslamers>no,
<bitwiz>Hang on, I think I understand what you're doing now
<mauritslamers>When I call that procedure with this sublist, I run a for-each on that sublist, setting the value of a key: (assoc-set! evt 'prop value)
<mauritslamers>assoc-set! will return a new list when the key didn't exist yet, which is why I have all keys already set
<mauritslamers>but for some reason it looks like that I am working on a copy of the event and not the orignal
<mauritslamers>can record types be "extended", something like derived or subclassing?
<mauritslamers>there is a set of shared properties / fields all events use, and type specific fields
<mauritslamers>ah, it looks like that is srfi99 which is not implemented by 1.8.7
<mauritslamers>but I might be able to deal with that by having a "common-properties" field, which is in it self another record
<bitwiz>About your list problem, though: the code you posted looks right to me (you get away with set! because object properties are 'procedures with setters'). What is (list evt) doing?
<bitwiz>Are object properties settable in Guile 1.8?
<mauritslamers>bitwiz: yes, they are
<mauritslamers>(list evt) is necessary when using append, because otherwise it would take the contents of the alist to add to the list
<bitwiz>So you end up with a new alist, right. When you set values in the new alist, I don't think there's any easy way to be sure the changed values affect the original alist, for the same reason that you need the set! here
<mauritslamers>originally this code was part of a huge closure, where I was using variables to keep track of these sublists, and that worked without issue.
<mauritslamers>but that function with closure was 300+ LOC
<mauritslamers>and not even half of the possible event types were implemented, so I tried a refactor to make things smaller and manageable. That has worked, but this bit is biting me still
<mauritslamers>bitwiz: I think I know my problem... the property name is wrong...
<mauritslamers>as in: in (assoc-set! obj key val) I am using the wrong key, which doesn't already exist
<mauritslamers>So, everything works as it should, just not me :D
***terpri__ is now known as terpri
***terpri_ is now known as terpri
***rekado_ is now known as rekado