# IRC channel logs

## 2020-08-01.log

back to list of logs

<jgart>how can I accumulate a list of lists by adding 1 to '(0 1 2) recursively until I reach 12 iterations of that process?
<jgart>Here is an example of my input and output
<jgart>any help is greatly appreciated
<jgart>(map 1+ '(0 1 2)) would give me just the first output: (1 2 3)
<mwette>(let loop ((res '()) (i1 0) (i2 1) (i3 3) (cnt 12)) (if (zero? cnt) res (loop (cons (list i1 i2 i3) res) (1+ i1) (1+ i2) (1+ i3) (1- cnt))))
<mwette>"(if (zero? cnt) res" => (if (zero? cnt) (reverse res)"
<RhodiumToad>(map (lambda (i) (list i (remainder (+ 1 i) 12) (remainder (+ 2 i) 12))) (iota 12))
<mwette>either works; I guess the named let is faster.
<RhodiumToad>if the (0 1 2) is actually an argument and could be anything, then how about
<RhodiumToad>(define (transpositions l) (letrec ((rot (lambda (o) (map (lambda (e) (remainder (+ o e) 12)) l)))) (map rot (iota 12))))
<jgart>I also got this way of solving it from #scheme irc
<jgart>(unfold (lambda (xs) (= (car xs) BOUND)) values (lambda (xs) (map 1+ xs)) '(0 1 2))
<jgart>zaifir shared that
<jgart>but his solution doesn't account for the modulo 12 wrapping
<jgart>RhodiumToad, I will try you last above now with letrec
<jgart>thanks alot!
<jgart>RhodiumToad, I imagined it could be solved recursively but wasn't sure. Iteratively recursive call is fine too?
<RhodiumToad>for a well-defined number of iterations, recursion seems overkill
<RhodiumToad>in my example I'm using (iota n) to generate the n-element list
<RhodiumToad>also the letrec there is out of habit, any binding form would work
<RhodiumToad>some people would have used a local (define)
<jgart>the lists that I would need to generate the "transpositions" for in the end won't be so easily formalized so to generated
<jgart>Here is one such complete list: https://paste.debian.net/1158515/
<jgart>RhodiumToad, but I appreciate you elegant solution for generating '(0 1 2)
<jgart>eventually that will be the input
<RhodiumToad>and for each of those elements, you want a 12-element list result?
<jgart>each indexed list will need to be transposed 12 times
<jgart>yes exactly
<RhodiumToad>using the one above with the letrec etc.
<jgart>those are the equal-tempered pitch class sets of cardinality 3 (i.e. musical three-note chords) https://en.wikipedia.org/wiki/List_of_pitch-class_sets
<jgart>RhodiumToad, Ok I will try now
<jgart>thanks!
<RhodiumToad>interesting, I wondered why the mod 12
<jgart>mod 12 because I want to model the pitch-class domain https://en.wikipedia.org/wiki/Pitch_class
<jgart>there are only 12 pitch classes but many pitches that are multiples of those 12
<jgart>sorry if I was two pedantic with the above. Just wanted to clarify the relationship of pitch and pitch-class
<jgart>that's exactly what I wanted (i.e. (map transpositions 3-1))
<jgart>very elegant solution!
<jgart>I will now try to study your solution so that I can assimilate what you just did. Great!
<jgart>RhodiumToad, I owe you a virtual beer
<jgart>so I can you plain let instead of letrec in your procedure?
<jgart>trying to read through it and follow the flow of execution to see everything that happens
<jgart>I have a general intuition for what is happening
<RhodiumToad>in this example any binding form would be fine. I just use letrec out of habit when binding procedures rather than values
<RhodiumToad>a local (define) would work too, e.g.
<jgart>why do you use letrec when binding procedures?
<jgart>I'm still not practiced in using letrec
<RhodiumToad>(define (transpositions l) (define (rot o) (map (lambda (e) (remainder (+ o e) 12)) l)) (map rot (iota 12)))
<jgart>ohh ok a nested (define)
<jgart>maybe that way is clearer to me for now
<RhodiumToad>letrec allows the bindings to reference themselves, the same way a (define) would
<jgart>right, where let does not
<RhodiumToad>i.e. (letrec ((foo (lambda ... (stuff here can reference "foo" for recursive calls)))) ...)
<jgart>let* also allows recursive calls?
<RhodiumToad>no, let* makes each binding visible to the following bindings, but not to itself.
<RhodiumToad>for both let and letrec, bindings are not visible to other bindings in the same form.
<jgart>right, I'm seeing that here: https://www.gnu.org/software/guile/manual/html_node/Local-Bindings.html
<RhodiumToad>letrec is normally not used for data because although the bindings are visible, it's not safe to actually try and access the values during binding initialization
<RhodiumToad>that's ok for functions, since you're not going to actually call the functions until you're in the body, hopefully (and letrec* is available for when that's not the case)
<RhodiumToad>the only real subtlety in this code is the use of l and o from inside (rot)
<jgart>rot is short for rotations?
<RhodiumToad>rename it as you choose, but yes
*RhodiumToad didn't know what the data was representing when writing that
<jgart>and "o" and "e" in the lambdas where chosen arbitrarily?
<jgart>no worries! I'm still working this all out myself
<jgart>ok, makes sense
<RhodiumToad>the point in this case is that we're using the lexically outer definition of "l" (as a parameter of (transpositions) within the body of the nested define,
<RhodiumToad>and in turn within the innermost (lambda) we have a lexical reference to "o"
<RhodiumToad>so within the scope of a single call to (transpositions) with some list as parameter, (rot 1) returns that list with all the values rotated by 1, etc.
<jgart>the map with lambda having single parameter "e" is consuming the "l" from transpositions
<jgart>very elegant!
<jgart>thank you RhodiumToad! I'm off to take a walk before sunset. Maybe I'll see you in this chat later. Thanks again!
***catonano_ is now known as catonano
***terpri_ is now known as terpri
<pkill9>how do you test if a given list is an association-list?
<daviid>i thought i did succeed in programatically (dynamically) perform the same as what is acheived by the #:replace define-module 'option', such as for example, in the (g-golf hl-api signal) connect variable name, which is bind in guile core and needs to be transformed into a generic function - however, what i have seems to have weird corner cases
<daviid>here is an example of what worksd, and a 'symptom' of what is or may be a problem
<daviid>if you launch a repl and enter connect, guile tels you it is a procedure, here #<procedure connect (_ _ #:optional _ . _)>
<chrislck>pkill9: you need to understand how to compare lists first
<chrislck>(member lst assoc-list) is the simplest one
<daviid>if you ,use (g-golf) and try that again, you'll see it became a generic function, with teo methods -| \$3 = #<<generic> connect (2)> - which exactly what is expected
<daviid>now, if you import GtkWindow, g-golf should do the same for short name methods, for example close, which the short name method for gtk-window-close
<daviid>(gi-import-by-name "Gtk" "Window") -| #<<gobject-class> <gtk-window> 562742d87900>
<daviid>however, close -| #<procedure close (_)>
<daviid>but it should be a generic function, which it is, but in the (g-golf hl-api gobject) 'only' [it did not replace, as i thought it would, the (current-module) binding] (@@ (g-golf hl-api gobject) close) -| \$6 = #<<generic> close (2)>
<daviid>the code that does the machinery is here - http://git.savannah.gnu.org/cgit/g-golf.git/tree/g-golf/hl-api/function.scm?h=devel - lines 247 - 275, and the specifric case for replacing a core or current-module binding is in lines 261 - 270
<daviid>if anyone is willing to help .. well, tx!
<daviid>what is weird is if you drop the following code - https://paste.gnome.org/pxw4m80m5 - in say 'hello-world.scm', chmod a+x and run it, _without_ any opned guile repl 'anywhere', it will compile execute and display i the terminal these lines (from the dimfi call, which is sort of a peek proc in g-golf ...)
<daviid>;; #<directory (guile-user) 559c4a121140>
<daviid>;; #<<generic> close (2)>
<daviid>but if you launch a guile repl, 'leave it' running, then try the same hello-world example again, if fails displaying these
<daviid>;; #<procedure close (_)>
<daviid>and then if you click the quit button, raises an exception of course, since it runs the core close proc over the window, instead of the appopriate method ...
<str1ngs>daviid when you have a sec can you take a look at the 'decide-policy signal in this example. http://paste.debian.net/1158525 . I tried to simplify this example as much as possible. run the script then and click on the Try it yourself button in the web page. this call some JavaScript to request a link in a new tab.. This use to work for me but now longer works. here is the documentation for the decide policy
<str1ngs>signal. https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#WebKitWebView-decide-policy My guess is WebKitPolicyDecision does not have the methods that WebKitNavigationPolicyDecision does.
<daviid>str1ngs: will take a look asap
<str1ngs>daviid: I'm reading the channel backlog maybe I can look into that abit.
<str1ngs>daviid: I could'nt get (run-javascript "window.open('https://gnu.org');" #f #f #f) so the example is more complicated then needed. probably the javascript world won't allow for window.open so you'll just have to click the link. applogies
<daviid>str1ngs: give me a bit of time, i actually have to clone g-golf to try your example :) because i am in the middle of this giinterface refactoring and your example neeeds those ...
<str1ngs>daviid: if this is something you are aware of it's not a rush. I can work around it for now. mainly i'ts used to create a new <web-buffer> when a link requests a new tab.
<str1ngs>daviid I'm reading channel backlog seeing if I can grok they problem you are having
<daviid>str1ngs: the example works, i click, nothing happens, but no bug either ...
<str1ngs>daviid: check the terminal output I have catch that outputs the error
<daviid>nothing in ther temnal either
<daviid>david@capac:~/alto/projects/g-golf/examples 92 \$ ./decide-policy.scm
<daviid>and the window with the example 'is there'
<str1ngs>you should see something like
<str1ngs>New Tab requested!
<str1ngs>Error: key: goops-error
<str1ngs>you click the Try this green button to execute the javascript?
<daviid>no 'try this green button' here
<str1ngs>it's in the browser window
<daviid>ah, didn't see that
<daviid>ok
<daviid>i can see the bug now
<str1ngs>it's okay I tried to example in the lable.
<str1ngs>err label*
<str1ngs>I could'nt just call the javacript manuall sorry I needed to use a link. so made the example more complex then I wanted.
<daviid>but i need to understand where is the callback code for this button
<str1ngs>the callback is decide-policy
<daviid>ok
<str1ngs>when something like window.open("https://gnu.org"); it requests to open the link in a new window. in nomad I just open the link in a new buffer.
<daviid>this seems to be called a million times, so to spea
<str1ngs>if I don't handle the decide-policy the click gets ignored.
<str1ngs>the only type I'm worried about is new-window-action
<str1ngs>I could just make a C helper function vi GI. to cast the types. that should get around it quickly if you are too busy
<daviid>str1ngs: i'm trying to understand why ... and what it seems to be is a webkit-policy-decision> instance is not what webkit-navigation-policy-decision-get-navigation-action expect as its frist arg
<daviid>you have to understand that i know nothong, or next to nothing about webkitgtk itself, so i'm in 'unknowen water' ... i'm fine, but it's not as i knew the answer out of my head just looking at it ...
<daviid>importing WebKit2 is not instantaneous, you might wna selectively import things there too .. just saying
<str1ngs>I'm pretty confident this worked at one point. this is the code in nomad as is. http://git.savannah.nongnu.org/cgit/nomad.git/tree/scheme/nomad/gtk/widget.scm?h=feature-g-golf#n172
<str1ngs>you can't find the method in g-golf?
<daviid>str1ngs: it could be yes - we need to find out why, when ... which commit ...
<daviid>no i can find t, the doc
<str1ngs>oh the doc, I can find that one sec
<daviid>actually, wait a sec
<daviid>let'1s see what tha cache expect
<daviid>so, that method expects a WebKitNavigationPolicyDecision
<daviid>but the example you paste pass a webkit-policy-decision>, which a super class instance
<daviid>that won't work in goops
<daviid>this is a very 'ruff' look at things
<daviid>we can digg further of course
<daviid>this why you need to cast in C by the way
<str1ngs>daviid: this reminds me of the gdk event thing
<str1ngs>similar special case anyways.
<daviid>get-navigation-action is a generic function. It's an instance of <generic>.
<str1ngs>daviid: btw in your hello-world.scm if you change to exec guile --no-auto-compile -e main -s "\$0" "\$@" it becomes consistent ;; #<<generic> close (2)> so it some compile bug
<str1ngs>or compile cache issue
<daviid>but in your example, you pass a <webkit-policy-decision>
<daviid>str1ngs: i don't think it is, but ... let's focus on one thing at a time :)
<str1ngs>with --no-auto-compile I have consistent <<generic> close (2)> just a FYI
<daviid>in g-golf, <webkit-navigation-policy-decision> is undefined, even after importeng the all webkitgtk
<daviid>it is a struct, not a 'real' gobject subclass
<daviid>it seems
<str1ngs>when I use (gi-import "WebKit2")
<daviid>oh, tipo on my side
<str1ngs>I got worried and though we had different WebKitGtk versions or something haha
<daviid>\$6 = #f
<daviid>but
<str1ngs> “navigation-action” property might not be set with make
<daviid>str1ngs: yes i was just 'playing ' with goops ...
<str1ngs>though #f is not a goops-error at least :)
<daviid>but i was passing the right argument
<daviid>to show you ...
<str1ngs>I can meant time just use C helper function that takes WebKitPolicyDecision and casts then returns WebKitNavigationPolicyDecision. it's pretty simple to do
<str1ngs>return WEBKIT_NAVIGATION_POLICY_DECISION (decision); should do it
<daviid>but it would be nice to understand and solve in scheme to ...
<str1ngs>I hear ya. I don't know what part of g-golf this effects. it's not related to interfaces I gues?
<daviid>what is 'casting' a type for another, internally, so we can maybe do it in scheme
<str1ngs>in gtk they use C macros to cast types. so WebKitNavigationPolicyDecision has WEBKIT_NAVIGATION_POLICY_DECISION
<daviid>it is difficult for me to ask about things i don't know ... let's see
<daviid>you are on #introspection as well
<str1ngs>I need to connect to znc one sec
<str1ngs>daviid: technically I'am and I get messages. but I don't always connect via znc. reading the backlog now.
<str1ngs>ebassi comments on quit() is useful
<str1ngs>unrelated of course :)
<str1ngs>daviid: probably for GI we should not cast. since language binding more then likely can't handle something like that normally. I guess #introspection can suggest how to do this.
<daviid>mean while i have an idea
<daviid>we/you could grab the g-inst slot value of the decision arg and use it to make a <webkit-navigation-policy-decision> instance
<daviid>that didn't work
<daviid>the pointer points to a webkit-policy-decision and needs to be cast
<daviid>that's total heresy
<daviid>:)
<daviid>str1ngs: by the way you ned to import goops before to set the duplicate handler, then import g-golf ...
<str1ngs>my example my need updating. normally I use goops via define-module anyways
<daviid>str1ngs: can you write, in your code, a casting func in C, so we could try?
<str1ngs>daviid: I'm looking at that now
<daviid>we could then try thiski
<str1ngs>two secs
<daviid> #:g-inst (cast-to-wnpd (!g-inst decision))))
<daviid>in the let of the callback ...
<str1ngs>hmm for somereason when I GI return WebKitNavigationPolicyDecision * it returns <webkit-policy-decision>
<str1ngs>let me try with your variant though
<daviid>you should only cast the pointer
<daviid>str1ngs: then youwould try this https://paste.gnome.org/pt932ar4m
<daviid>if you write the C func cast2wnpd
<str1ngs>I'm doing this via GI so I don't need to use !g-inst
<str1ngs>g-golf is already pasing the pointer
<daviid>you need to cast the gobject instance pointed by ...
<daviid>you cn't just take the <webkit-policy-decision> instance and make a <webkit-navigation-policy-decision> using it ... it will complain 'just the same way' ...
<str1ngs> http://paste.debian.net/1158528 when called with g-golf (dimfi (nomad-get-navigation-policy decision)) returns which is really od.
<str1ngs>odd*
<str1ngs>returns ;; #<<webkit-policy-decision> 55606bc3a4a0>
<str1ngs>daviid: I'm passing decicsion through g-golf via GI then I'm casing in C
<daviid>can you cast and check the type in C before to return?
<str1ngs>no, I'm calling the C code via g-golf not guile C. so g-golf passes the pointers
<str1ngs>(dimfi (nomad-get-navigation-policy decision)) works just it's returning <webkit-policy-decision> despite the C function casing with return WEBKIT_NAVIGATION_POLICY_DECISION (decision);
<str1ngs>so maybe it's only seeing the parent class here?
<str1ngs>g-golf that is?
<str1ngs>I could maybe use guile scheme and use pointers.
<str1ngs>err guile C
<daviid>I would try to write and ffi a cast2wnpd C snipset, then try what i proposed
<daviid>if that works, we can dig on your approach, which i know is more 'beautiful' ... but one step at a time
<daviid>i think
<daviid>you can patch libg-golf.c[h] just to see if it works
<daviid>str1ngs: can you describe (gi-cache-ref 'function nomad-get-navigation-policy) and see whast its return arg is?
<str1ngs>daviid: one sec
<str1ngs>daviid: that returns #f but nomad-get-navigation-policy returns \$4 = #<procedure 55e999382ba0 at g-golf/hl-api/function.scm:128:2 args>
<daviid>i thought you were using GI to import it
<daviid>hum
<daviid>then it is in the cache
<daviid>maybe a tipo?
<daviid>a tipo ...
<str1ngs>\$2 = #<<function> 563f85f5a540>
<daviid>ok, now describe
<daviid>it
<str1ngs>seems to be g-golf is using the parent class and not the child class
<str1ngs>describe output http://paste.debian.net/1158531
<daviid>so, this is correct
<daviid>return-type = interface
<daviid> type-desc = (object <webkit-navigation-policy-decision> #f 94830832738512 #f)
<daviid>if you call it, it should retur an instance of <webkit-navigation-policy-decision>
<str1ngs>right but when I pass decision it still returns ;; #<<webkit-policy-decision> 55be92345720>
<str1ngs>if I cast and C then get the uri string. and return cons *gchar I get the uri
<str1ngs> http://paste.debian.net/1158532 returns the uri for the new tab
<daviid>you still have the same repl you used to describe the function?
<daviid>so you could try (g-type-name 94830832738512)?
<str1ngs>I don't have the same repl
<str1ngs>where does 94830832738512 come from. that segfaults for me
<daviid>yeah, those types are dynamic
<daviid>in the paste of the describe ...
<str1ngs>it's in type-desc right?
<daviid>yes
<str1ngs>ah okay one sec
<daviid>i just don't know why your function does return a wrong instance
<str1ngs>(g-type-name 94389096412128)
<str1ngs>\$3 = "WebKitPolicyDecision"
<daviid>that is why
<str1ngs>one sec
<str1ngs>I use the wrong function
<str1ngs>gahh I took the wront type-desc
<daviid>ok
<str1ngs>(g-type-name 94389096412384)
<str1ngs>looks right now
<daviid>yes that looks correct
<str1ngs>dunno :(
<daviid>i can't try, that is a problem :)
<str1ngs>I'll just get the uri from C for now. I'm not sure why this is'nt working it did work at one point.
<daviid>the code that returns the value is here
<str1ngs>I don't think the function returns the wrong type. it seems g-golf is <webkit-navigation-policy-decision> handling correctly for some reason.
<str1ngs>not handling*
<str1ngs>maybe because it's an interface?
<daviid>no, these are 'object (GObject subclasses)
<daviid>the problem is i can't try, it doens't help :)
<daviid>the code that returns theinstance is here
<str1ngs>this function does need a transfer GI annotation. which I use Returns: (transfer full):
<daviid>line 1126 to 1132
<str1ngs>what do you need to try?
<daviid>now, can you add a line there, after 1129
<daviid>(dimfi class name g-type)
<daviid>before the line (set! (!type-desc funarg) ...
<daviid>man debugging this way is the worst situation of my carrer, ever
<str1ngs>debugging what way?
<str1ngs>I gave the example that cause issues. my helper function is was just to be a work around. be are getting side track. but I suspect it suffers from the same issue.
<daviid>ok, if you call it again, it shold prit these lines anymore, can tyou trry that
<str1ngs>as far as i can see it only prints it once
<daviid>ok
<daviid>what it printed, is the class of the instance it returns
<daviid>so, the call shoud return an instance of ;; #<<gobject-class> <webkit-navigation-policy-decision>
<daviid>you can see by yourself there is no other way, the instance is made line 1132
<daviid>using the class argument, defined by (g-object-find-class foreign)
<daviid>which returns the above ...
<str1ngs>well it returns <webkit-policy-decision>
<daviid>it returns either the reuslt of the line 1127 or 1132
<str1ngs>anyways we are getting side tracked with this function. lets assume it's the function's fault. I still need to get a <webkit-navigation-policy-decision>. if not I can just extend the C to return the URI
<daviid>str1ngs: i want to debug, i can not try
<daviid>as i said the worst situation ever
<daviid>if i could try
<daviid>can you try this
<str1ngs>you can use the example I gave you. the C helper function is just a work around really
<daviid>we are debugging that call
<str1ngs>right but but I can just extend the C function to return the value I really need which is the URI
<str1ngs>that does nothing to help for scheme in the long run though.
<str1ngs>I can push the to a branch if it helps
<daviid>str1ngs: to try i would need to be abe to do
<str1ngs>daviid: I pushed to decision-policy branch of nomad if it helps
<str1ngs>./pre-inst-env guile will give you a repl. and (gi-import "Nomad") imports the nomad namespace.
<str1ngs>make run starts a development browser
<daviid>str1ngs: i'm not going to do that
<daviid>to much
<str1ngs>you will need emacsy and shround though to build. the rest of the dependencies are in debina.
<str1ngs>well if you can't take time to build nomad. I don't know what to say.
<str1ngs>I'll work around the issue in C. meantime you can figure out why the example does not work.
<daviid>we know why the exmple does not work
<daviid>it needs a cast
<daviid>you write the cast in nomad, i cvan'1yt try it
<daviid>sorry
<str1ngs>no, casting is a C concept GI bindings normally do not cast. I could write this example in GIJS and pygobject and I'm confident that they are not going to cast. in fact this code worked then stopped working. I'm just reporting the issue to you.
<daviid>it needs a cast you can't just pass the pointer you have from the decision instance
<daviid>you can try yourself, as i did paste earleri, doing
<str1ngs>daviid: if you use this http://paste.debian.net/1158534 example with g-golf @ hash 30148389eed34a06f16e679be9ae59d9782d559f it will work. so somewhere between that hash and HEAD something broke.
<str1ngs>I just switched to long names the example is the same as before
<daviid>ok will look at this
<peanutbutterandc>Hello there. Is anybody here today? I have noticed that during the weekends the channel tends to get relatively quiter
<peanutbutterandc>s/quiter/quieter/
<peanutbutterandc>RhodiumToad, Hello there! :) I needed some help regarding this: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=42574
<peanutbutterandc>It is just a small issue (some mis-step on my part) I'm sure.
<peanutbutterandc>And I'd really like to be able to trace some of the recursive procedures that I am learning. I'd really appreciate a few pointers
<daviid>str1ngs: i found why it did work and now it's not
<RhodiumToad>peanutbutterandc: that does look like a bug
<str1ngs>daviid: okay is it an easy fix?
<daviid>no, but let me confirm a few things nhere first
<peanutbutterandc>RhodiumToad, I was hoping it would be just my mis-step... does it look like a simple bug, sir? Or would it requier some serious debugging?
<peanutbutterandc>s/requier/require/
<str1ngs>daviid: if it's not an easy fix. I can work around it. atleast you are aware of the problem now.
<peanutbutterandc>RhodiumToad, Also, it seemed to me that after a call to (trace-calls-to-procedure proc1) (proc1 x y z) ought to be traced no matter what. They aren't. (Or perhaps my expecations aren't correct?)
<daviid>str1ngs: well, the problem is it should not 'have worked'
<RhodiumToad>;; Note that because this procedure manipulates the VM trace level
<RhodiumToad>;; directly, it doesn't compose well with traps at the REPL.
<daviid>and now properly fails ... though i still need to try a few things before i can explain why and how to address these situations in newer versions of g-golf ...
<str1ngs>daviid: strange
<str1ngs>well I just use a C function to handle this meantime
<peanutbutterandc>RhodiumToad, I see that you are on the case, Mr. Holmes.
<RhodiumToad>that may be a red herring.
<RhodiumToad>the bug may, in fact, be very simple.
<RhodiumToad>trace-calls-to-procedure has this: (define (return-handler frame depth values)
<str1ngs>daviid: I revised my C function. instead of getting a WebKitNavigationPolicyDecision I'm just returning a WebKitNavigationAction. see http://paste.debian.net/1158538
<RhodiumToad>simply removing the "values" arg makes it work.
<RhodiumToad>looking at the place where that handler is called, in (system vm traps), it is only passed 2 args.
<daviid>str1ngs: ok but i really wish i could find out why the previous didn't work
<RhodiumToad>(print-return doesn't need to be passed the values, it gets them itself using frame-return-values given the frame parameter)
<peanutbutterandc>RhodiumToad, Does this mean that you will be submitting a patch soon, sir?
<peanutbutterandc>RhodiumToad, May I also ask why does the procedure have to be turned into a hunk and called with (call-with-trace (lambda () (procedure 1 2 3)) in the first place?
<str1ngs>daviid dunno
<peanutbutterandc>I was really expecting (procedure 1 2 3) to be traced after I did a (trace-calls-to-procedure procedure) call
<RhodiumToad>I would guess that the vm trace level is not set to enable traces by default.
<RhodiumToad>call-with-trace increments the trace level inside its dynamic context.
<peanutbutterandc>RhodiumToad, I see... so it is all just an extra formal argument in the procedure definition that is causing the trouble?
<RhodiumToad>(has the same bug, but should avoid needing to play with call-with-trace)
<RhodiumToad>looks like this is a regression from 2.2->3.0, in 2.2 the calling convention for the return handler is different, and it looks like the conversion to 3.0 was improperly done and not tested
<daviid>str1ngs: here is the exact commit that changes work/doesn't work anymore 2f161c81d99ebe8928ad3da0bfa94e1052152345
<peanutbutterandc>RhodiumToad, I just tried (add-trace-at-procedure-call! reverse) and it took me to a debug prompt. I have yet to learn about debug prompt well enough: with all the things about stack frames and all. Is there any lecture/book/manual that you'd recommend regarding the matter(s)?
<daviid>before that commit, methods were imported as procedures, and there were no short name methods
<RhodiumToad>peanutbutterandc: you need ,use (system vm trap-state) for that one
<daviid>after that commit, (gobject) methods are imported as goops methods, and g-golf provides short name methods
<RhodiumToad>peanutbutterandc: if you find yourself in a nested prompt, usually the most useful thing to do is to control-d out of it, unless you actually want to find out where you are
<peanutbutterandc>RhodiumToad, I did (use-modules ...) lol Let me try that then. Thank you for the pointer
<daviid>str1ngs: so, before, webkit-navigation-policy-decision-get-navigation-action is a procedure, there is no dispatch by goops on its first arguent
<RhodiumToad>(use-modules (system vm trap-state)) would have worked too
<RhodiumToad>the ,use is just a shorthand command in the REPL
<daviid>after the commit, webkit-navigation-policy-decision-get-navigation-action is a generic function, with one method, the argument of wich
<daviid>_must_ be and instance of a <webkit-navigation-policy-decision>
<daviid>and can't be a 'blindingly passed pointer' as it was before
<str1ngs>makes sense
<peanutbutterandc>RhodiumToad, No sir. It is still just throwing me into a debug repl. Am I supposed to see an actual trace?
<RhodiumToad>peanutbutterandc: what exactly did you see?
<daviid>ok, great, now, let's see how to addres this
<str1ngs>daviid: my nomad-get-navigation-action is probably not ideal since it returns a pointer for some reason. lol
<str1ngs>and (webkit-navigation-action-get-request action) doesnt seem to care
<daviid>let's focus on get-navigation-action and its argument
<RhodiumToad>peanutbutterandc: using add-trap-at... tells it you want to actually stop and go to the debug prompt when that function is called.
<daviid>it needs an instance of <webkit-navigation-policy-decision>
<peanutbutterandc>RhodiumToad, silly me. Sorry for the inconvenience. I will rectify the error right away
<daviid>but we know, because it worked before, that the decision instance pointer is/should be accepted, since that is what was passed before the commit
<peanutbutterandc>RhodiumToad, Yes, sir. It works. But stumbles upon the same error (I think it might be the same error) as the other one...
<peanutbutterandc>Wrong number of arguments to return-handler
<daviid>though i would prefer to cast the pointer
<str1ngs>daviid: I don't see how to do that in scheme. all I have is <webkit-policy-decision> so without same way in GI to convert to <webkit-navigation-policy-decision> there is not much I can do.
<RhodiumToad>you can just edit that line in system/vm/trace.scm and recompile it with guild compile
<str1ngs>maybe using glib primitives it can be converted
<sneek>wingo?, pretty sure was seen in #guile one month and 7 days ago, saying: all hail godbolt.
<sneek>civodul was last seen in #guix 3 days ago, saying: nckx: re truth.png :-).
<daviid>yes, if casting there is, it must be by calling a C function, just like we do in libgog-olf for gdk events ...
<peanutbutterandc>RhodiumToad, I see. Thank you sir. I will try to do just that. You're super awesome!
<str1ngs>daviid: casting is a C concept and Glib has C Macros that do that. I don't know how you would leverage that. #introspection should explain how to do this.
<peanutbutterandc>And sneek is so cool!
<daviid>but the thing is that it seems it should, in this specific case, accept a
<peanutbutterandc>Is sneek written in guile, too?
<RhodiumToad>peanutbutterandc: it's your bug, I'll leave it to you to post the patch
<str1ngs>daviid: its the generic method that causing the issue. for better or worse I guess
<RhodiumToad>as far as I know it is, yes
<daviid>because that 'mimic' what was before the commit
<peanutbutterandc>RhodiumToad, Oh no sir. I'm just a n00b. You should post the patch. I'm only an inspector Lestrade to your Sherlock holmes
<peanutbutterandc>Where can I see sneek's source?
<RhodiumToad>iirc it's not published anywhere? but I could be wrong
<daviid>str1ngs: well, we can rgue i gues, but goops is showing how superiror it is here, not the opposite, but let's this argument for academic ... let's try to solve it
<peanutbutterandc>RhodiumToad, I see... I hope you will be posting the patch soon, too, sir? I put the matter into your most capable hands. :) And off I go git cloning guile
<peanutbutterandc>RhodiumToad, I really don't think I should take credit for your work. One person reporteth. The other fixeth it. Perhaps? But if you insist I will make the change (with the proper credit in the commit message, of course)
<RhodiumToad>you don't have to take credit, you can credit me for it all you like
<peanutbutterandc>But I must send a patch in myself?
<RhodiumToad>what you _don't_ get to do is dictate how I spend my time.
<peanutbutterandc>I am sorry sir. That was not my intention.
<peanutbutterandc>If anything, I am most grateful for you having resolved this issue for me. Thank you very much. I will put in a patch and will credit you in the commit message.
<peanutbutterandc>Strange, `info guile` does not have a 'submitting patches' or 'contributing' section (the regex search fails)
<peanutbutterandc>looking elsewhere
<daviid>wow
<daviid>:)
<peanutbutterandc>RhodiumToad, Please pardon me but https://www.gnu.org/software/guile/contribute/ says that I ought to turn the example that triggers the bug into a test case. I don't know anything about writing test cases in guile. Do you think it is okay to not write a test case since this is only a matter of removing a formal parameter from the definition?
<chrislck>It's easy to write a test case.
<chrislck>(I haven't followed the above bug hunt closely)
<peanutbutterandc>chrislck, I am a n00b. May I please be directed to a resource for writing tests in guile please?
<chrislck>Write the minimum LOC to trigger the bug
<RhodiumToad>(define (foo l) (if (null? l) '() (append (foo (cdr l)) (list (car l)))) (add-trace-at-procedure-call! foo) (foo '(1 2 3))
<RhodiumToad>doesn't matter what the function does as long as it recurses
<RhodiumToad>er, I think I missed a paren in there
<peanutbutterandc>Since I am a python-n00b too, I remember seeing unit test module in python. And, if used properly, one could only run the tests. I was wondering if there was something similar in guile
<daviid>str1ngs: look at this https://paste.debian.net/1158540/ - or how g-golf won't let users do what they want :):)
<peanutbutterandc>...tests only
<daviid>not even its author haha
<chrislck>don't worry about writing unit tests in guile... just minimum LOC to demonstrate a bug, and send to bug-guile@gnu.org, and magically some guile hacker will get round to it
<peanutbutterandc>chrislck, Some guile hacker did get round to the issue and did fix it and has told me to send in the patch. And now here I am, feeling like I'm pushed into the Operation Theater in my first year of med school :D But I think I'll learn a bit from this experience. :)
<peanutbutterandc>Just cloned the repo :)
*RhodiumToad is just zis guy, you know?
<chrislck>IIUC No Rhodium didn't fix it, just pointed out how. The main repo still has bug.
<RhodiumToad>though I suppose I do count as a contributor since my name is in the commit log now, indirectly
<peanutbutterandc>And that is why I don't want to take the honour from you. You should have your name in the contributor list. Proudly. But that is just my opinion sir.
<peanutbutterandc>But I am preparing sending in the patch. Because you have asked me to. And orders are orders.
<chrislck>ditto. as a bug reporter my name is now immortalised but the bug fixer is still wingo: http://git.savannah.gnu.org/cgit/guile.git/commit/?id=cf53854d42d4e260459896cb0c4b071608398b96
<chrislck>(still no idea what's the bug that's just been found)
<peanutbutterandc>chrislck, This one: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=42574
<RhodiumToad>looks like an editing error when converting 2.2 -> 3.0, and not tested
***jonsger1 is now known as jonsger
<peanutbutterandc>Hmm... there seems to be a bunch of .test files in the repo, under 'tests' sub-dir, that use (test-suite) module...
<peanutbutterandc>but since there isn't a trace.test perhaps I won't need one (?)
*RhodiumToad compiles up latest guile on his raspberry pi
<RhodiumToad>still need to patch the off_t thing for 32-bit freebsd :-(
<chrislck>... all this talk of of peanut butter and pie gets me hungry
<chrislck>srfi-180 is finalised. does it mean I could grab https://github.com/scheme-requests-for-implementation/srfi-180/blob/master/srfi/180/body.scm and use it as is?
<chrislck>none the files on that repo are loadable as is in guile
<chrislck>i.e. although it's finalised, the repo code is not usable
<peanutbutterandc>Okay... this is stupid, but how do I compile guile, again? `autoconf && ./configure && make` ? o.O
<peanutbutterandc>I am such a n00b
<daviid>str1ngs: so, you/we are being bitten by a fundamental principal/rule/hypothesis and a pillar at the 'heart' of g-golf design: instances are unique - to a gobject instance correspond one and only one goops instance and vis-e-versa
<peanutbutterandc>I have done `guix environment guile` then `autoconf` then `./configure` throws an error "can't find install-sh, ... in ./build-aux"
***sputny1 is now known as sputny
<daviid>str1ngs: hence, gobject instance pointers can be and are cached, so when a gobject lib returns an instance, g-golf returns its goops instance ... pretty obvious one could say ... this is 'hard coded' in g-golf using the mop (the meta object protocol), which is good
<peanutbutterandc>It appears that `guix environment guile` doesn't give me automake and friends that are required to run autogen.sh. Any ideas as to what might be going wrong here?
<daviid>str1ngs: i see two solutions: (1) copy the gobject instance, so it's a new pointer, we can use it to create a new goops instance or (2) remove the instance from the cache, keeping its gobject instance pointer, so we can create a new goops instance as well
<daviid>in the second case, one must be sure the instance to be removed is not referenced (a user responsibility I mean) and g-golf could provide a 'cast' method which would do exactly that, keep the gobject pointer, remove the revious instance from the cache, and then create and cache a new instance
<daviid>in this scenario, it would be the user responsibility that the 'new' class for the gpointer is 'adequate', like it would be the case for this example we are talking about
<daviid>str1ngs: I didn't know that casting, in C, does preserve original pointer address(es) - in this paste https://paste.debian.net/1158528, i assumed the returned pinter would always be new
<RhodiumToad>peanutbutterandc: I don't use guix, sorry
<peanutbutterandc>RhodiumToad, I see. It's all right sir. I am trying the normal route now (without guix environment)
<RhodiumToad>just ./configure && make should do, btw
<RhodiumToad>though you may need to do things like specify the correct libgc library to use according to whether threading is enabled or not
<peanutbutterandc>RhodiumToad, I finally got autogen.sh running but it currently gives me AM_GNU_GETTEXT macro not found in library error thingy
<peanutbutterandc>I think I have an idea... just a sec
<ArneBab>RhodiumToad: do I see it correctly that your letrec-solution is equivalent to this?
<ArneBab>(define (transpositions l) (define (rot o) (map (lambda (e) (remainder (+ o e) 12)) l)) (map rot (iota 12)))
<RhodiumToad>they should be exactly equivalent, yes
<ArneBab>ah, sorry, you showed that next — sorry for the noise :-(
<ArneBab>but a pretty cool solution
<peanutbutterandc>Okay this might be really stupid... but I can't seem to figure out where is the built guile (built from source)
<peanutbutterandc>anybody here?
<dsmith>sneek: bugs?
<sneek>I could be wrong, but bugs is Send reports to bug-guile@gnu.org, and see bug reports at https://bugs.gnu.org/guile
<dsmith>peanutbutterandc: ^^
<peanutbutterandc>dsmith, I am sorry? o.O
<dsmith>peanutbutterandc: To submit a bug report, send it as an email to the above address
<peanutbutterandc>dsmith, Oh... it wasn't a bug... turned out to be my ~/.guile causing the problem. A good little -q and the issue was gone. Thank you nevertheless.
<peanutbutterandc>dsmith, If you're still here, where exactly do I sent in the patches?
<peanutbutterandc>sneek, patches?
<peanutbutterandc>sneek: patches?
<peanutbutterandc>Is it just me or does the contributing page not tell where to send in patches? https://www.gnu.org/software/guile/contribute/ ? o.O I am really confused
<peanutbutterandc>Do I send the patches to the same email thread as the bug report in question? o.O
<mwette>yes ; attach the patch to the email going to bug-guile@gnu.org
<peanutbutterandc>mwette, I see. Thank you very much. :)
<dsmith>peanutbutterandc: Yes, send in the patches with the bug report
<peanutbutterandc>dsmith, I see. Thank you. :)
<ArneBab>mwette: can we treat the question by peanutbutterand… as bug report about the contributing page? Maybe change from
<ArneBab>"Please send a patch and commit log as produced by git format-patch." to
<ArneBab>"Please send a patch and commit log as produced by git format-patch to bug-guile@gnu.org."
<dsmith>I'd send a patch about fixing how to send a patch but I can't find out how to send a patch...
<ArneBab>:-)
<ArneBab>(point taken, I’ll send a patch when I get to it)
<mwette>the instructions are on the guix page IIRC
<mwette>looking ...
<mwette>... only finding the following which is guix specific and does not indicate how they want the git log entry written : https://guix.gnu.org/manual/en/html_node/Submitting-Patches.html#Submitting-Patches
<mwette>here it is, starting line 82: https://git.savannah.gnu.org/cgit/guile.git/tree/HACKING
<str1ngs>daviid it keeps the same pointer. with GLib the C macros that cast to type checks etc. it's considerbly safer with GLib then just doing. WebKitNavigationPolicyDecision *navigation_decision = (WebKitNavigationPolicyDecision*) decision.
<str1ngs>daviid: what types are effected by this issue. derived interfaces?
***terpri_ is now known as terpri
<ArneBab>dsmith: in case you’re trying it out: I pushed some improvements for streaming video with wispserve: https://hg.sr.ht/~arnebab/wispserve
<ArneBab>it now uses small chunk sizes at the beginning öf the file (32KiB), then 256KiB within the first 2MiB and afterwards 2MiB chunks.
<pkill9>what's wispserve?
<ArneBab>pkill9: wispserve is a small local fileserver I built after I searched fruitlessly for two hours for "simple way to stream local files so I can watch them in a webbrowser on another computer"
<pkill9>nice
<pkill9>so like python's http module
<dsmith>ArneBab: Why the increasing chunk sizes?
<ArneBab>pkill9: not quite as convenient (it shows all files, no folder structure)
<ArneBab>dsmith: because when you’re accessing a video from the browser, having a big initial chunk introduces wait times (in my local test 32KiB take 11ms, 256KiB already take 70ms). Afterwards I want to reduce the overhead from additional requests
<ArneBab>dsmith: that’s just from local testing, because browsers do not really request the sizes as they are optimal
<dsmith>Nice. Initially optmize for latency, later for bandwidth.
<ArneBab>dsmith: the reason that got me to check that initially is that I get GC warnings when I access large files.
<ArneBab>(that’s the not-that-glorious reason :-) )
<dsmith>heh
<ArneBab>but yes, in hindsight it’s a good idea :-)
<ArneBab>now it works pretty well.
<ArneBab>though most stuff is still missing — like mime types
<ArneBab>for anything but text and video
<ArneBab>do we have a library with extension-to-mime-type mappings?
<str1ngs>ArneBab: it's not ideal but you call file -i /path/to/file to get a mime type
<str1ngs>which is better then extensions since it uses file magic. just requires file program
<str1ngs>ArneBab: I did also find this https://www.nongnu.org/guile-www/doc/mime_002dtypes.html which has mime-types<-extension. part of guile-www
<str1ngs>though I think file magic is better IMHO :)
<a_v_p>I finally managed to post Guile-SSH 0.13.0 release announcement to the guile-user ML: https://lists.gnu.org/archive/html/guile-user/2020-08/msg00004.html
<a_v_p>Had problems with Emacs Gnus configuration, so my previous messages got lost on the way to the ML.
<dsmith>I need to get back to using Gnus. TimeWarner/Spectrum has totally broken their webmail interface.
<ArneBab>str1ngs: I now moved to file-magic, but also had to change from checking that for every request to tracking it in the downloadable files, because I cannot afford the second disk-access for every chunk.
<ArneBab>I didn’t think that that would have such a big effect, but it does
<str1ngs>ArneBab: yeah it's not ideal due to the fork called either.
<str1ngs>s/called/call
<str1ngs>ArneBab: I'm assuming file-magic using file -i?
<ArneBab>it’s now only called when the file is first accessed (which is also when I ran sha256 over the file so it can be accessed via uri-res/raw/urn:sha256:<sha256>
<ArneBab>str1ngs: actually file --mime-type, because the content type from file isn’t the one I need in the webserver
<ArneBab>(I need "ISO-8859-1", because of reasons?)
<ArneBab>(I guess it’s the standard port encoding)
<str1ngs>right
<ArneBab>when I pass that as charset the browser correctly decodes what it gets
<ArneBab>I’m a bit worried about GC problems, though.
<str1ngs>are you using (web server) ArneBab ?
<ArneBab>str1ngs: I’m actually using (fibers web server) by wingo
<ArneBab>str1ngs: crazy idea: in this server I implemented pre-liminary X-Alt and X-NAlt support so downloads could be retrieved from multiple sources without the need for a tracker
<ArneBab>str1ngs: is that something you could pull into nomad?
<str1ngs>Assuming it uses handlers like (web server) I guess you might have a static file handler in this case?
<ArneBab>yes
<str1ngs>it should be cheap to get the mime type just before opening the file. file magic tends to read a limited amount of bytes
<ArneBab>it’s actually not cheap, because I serve range requests and separate them
<ArneBab>what I do is getting the mime-type for the file if I don’t know it yet
<str1ngs>failed successfully!
<ArneBab>:-)
<ArneBab>str1ngs: the file-server retrieves the shared files at startup and then checks its vhash path->file to get metadata about the file
<ArneBab>str1ngs: and every file is a record: served serverpath accesspath size mimetype sha256
<RhodiumToad>dammit, now I have to recompile it all
<ArneBab>str1ngs: the part I worry about is read-performance. I fear that I’m still much to inefficient there: https://hg.sr.ht/~arnebab/wispserve/browse/wispserve/serve.w?rev=tip#L267
<ArneBab>(port (open-input-file abspath #:binary #t)) → (data (if end (get-bytevector-n port (+ 1 (- end begin))) (get-bytevector-all port)) → bytevector->string data "ISO-8859-1"
*ArneBab just saw where he actually gives the encoding explicitly … <facepalm>
<str1ngs>ArneBab: do you hash the files are server startup?
<str1ngs>s/are/on
<ArneBab>yes, or at first access if I pass --lazy
<ArneBab>for the future I still need to hash chunks so they can be validated
<str1ngs>I guess that is not bad. alternatively you could just hash the restful path for uniquness
<ArneBab>The hash is also intended to provide validation of a file downloaded from many sources
<str1ngs>hashing chunks seems sophisticated :)
<str1ngs>does this do P2P?
<ArneBab>I want to implement a variant of the Gnutella Download Mesh: swarming as with bittorrent but using standard HTTP
<str1ngs>interesting idea. I wonder if maybe gnunet would be helpful here?
<ArneBab>that it became a video streaming tool is more or less an accident (I wanted to stream videos to our TV)
<ArneBab>AFAIK GNUnet is much to complex for that
<str1ngs>I thought it had the building blocks for this. ie distributed hash table . whih is what bittorrent is based off of
<ArneBab>What I’m missing for full compatibility with actual Gnutella-clients is a TigerTreeHash implementation
<ArneBab>That’s all much more complex than what Gnutella used very successfully
<str1ngs>I trust your judgment here, it's kinda out of my knowledge base.
<str1ngs>also there is IPFS though that would lake guile bindings.
<str1ngs>lack*
*ArneBab used to be moderator on the gnutella development list when he was still useless at coding …
<ArneBab>IPFS is BitTorrent again :-)
<str1ngs>ahh that makes sense.
<ArneBab>That’s why I can grab for rough memories to find my way back into the RFCs
<str1ngs>btw this might be useful for guix in the context of P2P substitutes :)
*ArneBab started giving a spring lecture about distributed systems in 2019 to help keep those developments known
<ArneBab>that’s why I started doing it in Scheme, I just didn’t get it to a state yet, where I could integrate it and file a pull-request so Guix substitutes could be swarmed by all those who need them
<str1ngs>there was some talk of use IPFS due to NIX's interest in that protocol. not sure where that is at.
<ArneBab>IPFS is a nice system, but it needs a tracker. What I like so much about the Gnutella Download-Mesh is that it needs minimal support from the server
<ArneBab>The server can even die and all members of the swarm can still complete their downloads (if enough stay active after they finish so the whole file is still available).
<str1ngs>I guess it needs a seed swarm?
<ArneBab>It needs a seed-server which hands out the IPs of the most recent requesters
<ArneBab>also it needs validation data for the chunks
<ArneBab>Gnutella used a merkle-tree to provide that validation
<str1ngs>IPFS uses merkle-tree's as well.
<ArneBab>I’m thinking about simplifying that as BitTorrent did it and just providing a list of chunk-hashes, though it won’t be compatible then :(
<str1ngs>simple is better. I like the idea regardless. the less centrally the dependent the client's are the better.
<ArneBab>IPFS uses mekle-trees?
<ArneBab>In theory I prefer merkle-trees: then the server can simply provide the merkle-tree root and the clients can exchange ranges themselves.
<str1ngs>it uses Merkle DAGS
<ArneBab>AFAIK that’s merkle-trees by another name :-)
<str1ngs>great marketing! :P
<pkill9>is there a way to readlink recursively and get the final directory?
<ArneBab>Ah, no "there are no balance requirements" ← DAG vs. Tree
<str1ngs>pkill9: you can use FTW https://docs.ipfs.io/concepts/merkle-dag/
<ArneBab>^ nerdsniped me …
<pkill9>str1ngs: I'm not sure that does what i want, I want the functionality of 'realpath'
<RhodiumToad>... and you can't use realpath?
<str1ngs>pkill9: think canonicalize-path can get absolute path, I think that's what you want?
<pkill9>yea i realised i can, i'm shelling-out atm
<pkill9>str1ngs: that works, thanks
<str1ngs>I could have misunderstood what you meant by realink. I assumed you wanted to walk a path then get the absolute path of the last directory.
<str1ngs>hopefully I understood that correclty
<pkill9>yea, i thought ftw is for going through directories
<RhodiumToad>hm, why is there no (realpath) in the posix module?