IRC channel logs

2020-09-20.log

back to list of logs

<leoprikler>Scheme is magical.
<leoprikler>1/0 != (/ 1 0)
<stis>changed the for semantics, now this hack works
<stis>(for ((x : l)) ((c 0)) (+ c (1/0 (f x))))
<stis>special case, returns final value of c
<stis>manumanumanu: did a python for loop with less set! and more pure as we do not assume python variable semantics anymore. Much cleaner.
<stis>yielding values and dynamic-wind and try/catch finally ideom typically yo would not want to execute finally when you yield over it
<stis>take as an example where you close a file in the final statement of a with statement
<daviid>.
<sneek>Welcome back daviid, you have 2 messages!
<sneek>daviid, str1ngs says: Hello I found another bug in g-golf see this example https://paste.gnome.org/pw0t0lrhr. Essentially (append-page (make <gtk-notebook>) (make <gtk-label> #:label) #f) should work. but the method to handle #f does not exist.
<sneek>daviid, str1ngs says: appropriate append-page documentation. https://developer.gnome.org/gtk3/stable/GtkNotebook.html#gtk-notebook-append-page
<daviid>str1ngs: the https://paste.gnome.org/pw0t0lrhr link xpired, could yu repaste it, tx (I could write one, but ... since you have a snipset I'll use it)
<str1ngs>daviid: should work I updated it for one week. https://paste.gnome.org/pw0t0lrhr
<str1ngs>daviid: on sec, maybe I wrongly reported this.
<str1ngs>daviid: I revise the example if you need a simpler test case let me know. I was just testing some other things as well.
<dsmith>leoprikler: I mean, you can't define 2/3, but you can 1/0
<dsmith>scheme@(guile-user)> (define (1/0) (display "Hello 1/0\n"))
<dsmith>scheme@(guile-user)> (1/0)
<dsmith>Hello 1/0
<dsmith>scheme@(guile-user)> (define (2/3) (display "Hello 2/3\n"))
<dsmith>While compiling expression:
<dsmith>Syntax error:
<dsmith>unknown file:3:0: source expression failed to match any pattern in form (define (2/3) (display "Hello 2/3\n"))
<RhodiumToad>2/3 is a number, but 1/0 is a symbol? that seems like a bit of a gotcha
<marusich>Is there any "IDE" for Guile besides Emacs+Geiser? Like, maybe a generic scheme IDE that can be plugged into Guile? DrRacket is neat for Racket, but I haven't heard of anything for Guile.
<johnjay>i didn't know geiser was an interface for guile, thanks for letting me know that
*johnjay tfw you read a stackexchange question but don't even need to see the answer
<daviid>str1ngs: another good catch, tx. Although I know what to do, effectively implementing the fix needs some thoughts and a bit of time, will ping you when I have something to test
<str1ngs>daviid: no worries, this is easily worked around with the last argument being (make-label (format #f "Page ~a" (1+ (get-n-pages notebook)))) so it's still usable unlike the 'parent-set issue.
<str1ngs>daviid: is there a dynamic way to check if a parameter is [allow-none] which I guess is NULL or as a scheme type #f.
<daviid>str1ngs: yes there is
<leoprikler>dsmith: interesting
<leoprikler>it seems that "/0" doesn't count
<rekado>marusich: when I had more time I thought we could offer a pre-configured Emacs with Geiser, Flycheck, the picture language, etc. This exists now, but is not complete. “guix install guile-studio” gives you that thing.
<marusich>Amazing. Thank you for pointing me there! I was looking at the way you packaged it, and it's quite a nice little bag of tricks :) I will give this a try the next time I want to mess with Guile code.
<rekado>marusich: great! If you notice something that’s especially annoying about it, please do let me know. I don’t have much time to polish it, but I’d like to remove as many big annoyances as possible anyway.
***terpri_ is now known as terpri
<dsmith>leoprikler: It's just not rational
<leoprikler>Well 2/3.142 is also unset
<leoprikler>as is 2/3.0
<leoprikler>or even 2/3. and 2/3?
***dddddd_ is now known as dddddd
***deesix_ is now known as deesix
<leoprikler>Back to my questions about syntax, how do I use stuff like '=>' and 'else' in syntax rules?
<RhodiumToad>what kind of thing do you want to do?
<leoprikler>A variant of "if" with slightly funny syntax
<RhodiumToad>both syntax-rules and syntax-case take a list of "keywords" which are to be treated literally
<RhodiumToad>so e.g. syntax-rules (=>) ..stuff..
<leoprikler>(if* key then else) should look up the key in a hash-table and run then/else based on it
<leoprikler>(if* (test => key) then else) should save the result of test in the hash-table under key and run then/else
<leoprikler>I tried matching with (_ (test => var) then else) ...) but regardless of whether I have (=>) in syntax rules I get:
<leoprikler>unknown location: =>: bad use of '=>' syntactic keyword in subform => of =>
<RhodiumToad>can you show a whole definition?
<leoprikler>hmm
<leoprikler>the following should do it: https://paste.gnome.org/puv9qjjiv
<RhodiumToad> https://dpaste.org/ziVc
<leoprikler>Ahh, I forgot my quotes
<RhodiumToad>order of rules matters
<RhodiumToad>(_ var then else) will match (if/table (a => b) x y) with (a => b) bound to var
<leoprikler>nice, two errors for the price of one
<RhodiumToad>so you need to test the => version first
<RhodiumToad>is var supposed to be just a symbol?
<leoprikler>yep
<RhodiumToad>you might want a clause ((_ (x . y) . z) (syntax-error ...)) in there somewhere then
<leoprikler>oof, I just realized i renamed the syntax
<peanutbutterandc>Is there any way in emacs to see 1. which module a certain procedure comes from and 2. the definition of the procedure - all while the .scm file is loaded?
<rlb>Do we expect risc-v builds to work yet? (Looks like all the debian release architectures built fine after the ports.test fix, but a number of non-release architectures are failing. Of them, I suspect risc-v is the one that's most likely to eventually be required to work, so I wondered: https://buildd.debian.org/status/package.php?p=guile-3.0&suite=sid )
<rlb>guile always auto-compiles to XDG_CACHE_HOME or HOME/.cache? i.e. it never compiles to any kind of shared dir, right?
<rlb>And am I correct to think that since auto-compilation knows nothing about macro-derived dependencies, any changes at that level have to be considered API breaking changes, i.e. you might have to change the module's major version if you're following semantic versioning? And if so, is that fairly well understood/respected?
<rlb>I'm asking because we're discussing debian's scheme packaging arrangements right now, and I want to make sure I'm thinking straight about the constraints.
<rlb>(on the new debian-scheme list, fwiw)
<apteryx>how can I query the available physical memory of the system?
<apteryx>doesn't seem to something directly available to use
<apteryx>seems I want to query PAGE_SIZE from sysconf: https://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html
<rlb>From guile? Don't know of a built-in function offhand. If course you could run "free -m" or equivalent and parse the output.
<apteryx>yeah, from Guile
<rlb>If nothing else, I'd likely just exec sysconf if that has what you want.
<rlb>oh, wait, I was thinking there was a posix util for that (is there?)
<apteryx>seems more like a standard C lib
<rlb>yeah, though sometimes there's a corresponding utility, but I'm likely just misrememvering.
<rlb>"remembering"
<rlb>Might be plausible for guile to add sysconf wrappers...
<apteryx>guix doesn't know about a sysconf package at least
<rlb>getconf
<apteryx>ah!
<rlb>$ getconf PAGE_SIZE
<rlb>4096
<rlb>
<apteryx>I have to multiply the number of pages by the page size
*rlb is not entirely crazy, or at lest this doesn't add any evidence.
<rlb>There's also /proc/meminfo if you don't need to be as portable.
<rlb>And free *might* be sufficiently portable, not sure.
<manumanumanu>leoprikler: (regarding the loop) the problem with set! is that it involves implicit boxing. you will get a "mutation" penalty for that, which will most certainly not produce optimal code. The beauty of foof-loop (or my own racket for loop clone) in that they are not much more than pretty versions of fold and fold-right.
<leoprikler>rlb: regarding compilation, yes autocompile goes to XDG_CACHE_HOME, but it also reads compiled code from GUILE_LOAD_COMPILED_PATH, which on traditional Linux distros includes /usr/lib/yadda/yadda
<rlb>OK, thanks, and that's what I thought, and this is in the context of "What should happen when someone runs 'apt install slib'"?
<stis>manumanumanu: I redesign the pytyhon for loop macro much less set! and cleaner now.
<manumanumanu>stis: do you have the code somewhere?
<rlb>i.e. since slib works with multiple schemes, it may need to compile at install time, and/or (re) compile all child dependencies, etc. (because macro changes).
<leoprikler>slib code should get compiled for $GUILE_VERSION and put into the right /usr/lib/yadda/yadda
<stis> https://gitlab.com/tampe/scheme-python/-/blob/master/modules/util/scheme-python/for.scm
<rlb>We're just thinking through some of the issues.
<rlb>right, but we also can't let anything *use* slib before that happens, or we'll end up auto-compiling as root, etc.
<leoprikler>IIRC apt handles version changes e.g. python2-numpy vs python-numpy
<rlb>So we have to get the dep order right, etc.
<rlb>The python packaging tools have to handle that.
<rlb>(which end up being called or producing artifacts for apt, but apt itself doesn't know anything about it)
<stis>manumanumanu: but the protocal means that you throw StopIteration to end the loop and to know the value in the error handler you need set! due to ellse you need to to a catch on each iteration which is way more expensive
<rlb>(And so we're starting to discuss what we might want to do (if anything new) for the debian scheme "add on" packages, and may end up with something like whatever python does, or debian-emacs-policy, or... Not sure yet.)
<leoprikler>rlb: GUILE_AUTO_COMPILE=0 usually during `make' invocations (i.e. developers set that)
<stis>but much cleaner now
<manumanumanu>stis: it still looks a lot cleaner. not much code :) My guile for loops is the result of me learning syntax-case as I go...
<manumanumanu>stis: I added a generalized right fold btw. Now you can express for/list as a chain of conses. https://hg.sr.ht/~bjoli/guile-for-loops
<leoprikler>IIRC debian usually distributes the binaries (i.e. the already compiled files), so that's that
<rlb>It doesn't for emacs or python, and likely other ecosystems.
<manumanumanu>The code is horrible though, and the approach was bad, since you cannot express something like (for/stream ((a (in-transform 0 b)) (b (in-transform 1 (+ a b)))) a) for a stream of fibonacci numbers.
<rlb>In the limiting case, we also likely need to rebuild *all of the .go files for all of the add on packages in the right order, every time guile-X.Y is upgraded.
<rlb>*all*
<rlb>Which is what debian emacs does.
<rlb>(given the concerns wrt macro changes)
<manumanumanu>stis: what you want to look at is for/emit in loop/source if you want to know what the loops outputs :D With what I know today I could probably just implement it in half as many lines.
<stis>manumanumanu: i always redesign things that are not much used constantly improving, to stck with a bad design is too easy it should be better to do retrys as today i see way too much overdesigning from the beginning to avoid redoning things
<manumanumanu>yeah!
<manumanumanu>I find sharing things with the world makes me critical of it in ways that are positive. The transducers srfi, and moreso the inclusion in guile, would never have gotten anywhere unless arthur asked me to make a srfi out of it, or if I knew andy or ludo would look through it.
<manumanumanu>the srfi process is scary to someone like me. mostly in a good way.
<stis>processes and documentation is well worth to have well implemented stuff that goes in
<peanutbutterandc>Hey there
<peanutbutterandc>Is it just me, or does emacs-geiser not work well for someone else too?
<peanutbutterandc>Or, perhaps I am just not able to figure out it's usage....
<peanutbutterandc>But, I did try following the manual. Did M-x run-guile, and then M-x geiser-eval-buffer and yet, I can't get any documentation
<peanutbutterandc>I'm using guile 3.0.4 and emacs-geiser 0.11.2, both from gnu guix
<peanutbutterandc>any ideas, please? Maybe I'm missing something?
<leoprikler>rlb: I'm on Guix, so I don't really see the problem with rebuilding anything