IRC channel logs

2021-04-30.log

back to list of logs

<daviid>i pulled the fixes, so now the error tells me where/what, i see the following raises the exception - (define (foo bar) (lambda ( . args) ... )) -> invalid argument list in subform args of args
<davexunit>I sort of have a basic tree shaker working. something is wrong, though. seems like there may be some things that are needed that don't show up when walking the module tree.
<davexunit>"Unbound variable: read-syntax" uh oh
<davexunit>the big issue though is "class not found <dynamic-object>" when loading goops.
<davexunit>not really sure how this magic happens.
<davexunit>the good news is that this approach seems promising. the resulting bundle is 41MB smaller than my original that includes everything.
<davexunit>a-ha, goops.c iterates over each smob and makes a class. the SCM_SMOBNAME macro fetches the name, so there's no explicit reference to dynamic-object here.
<davexunit>I'm curious what my bundle is missing that there is no dynamic object smob type
<flatwhatson>./module/oop/goops.scm-3315-;; <dynamic-object> used to be a SMOB type, albeit not exported even to
<flatwhatson>./module/oop/goops.scm-3316-;; C. However now it's a record type, though still private. Cross our
<flatwhatson>./module/oop/goops.scm-3317-;; fingers that nobody is using it in anger!
<flatwhatson>./module/oop/goops.scm:3318:(define <dynamic-object>
<flatwhatson>You must be shaking that tree a little too angrily?
<davexunit>I think I know the issue.
<davexunit>I think I've mixed things up between two different builds of guile that I have.
<davexunit>and that recent change around how the <dynamic-object> class is created is causing problems.
<davexunit>got it working. :)
<davexunit>a few quirks, but pretty cool.
<davexunit>bundle size reduced by 39MB.
<davexunit>tarball download size reduced by 8MB
<davexunit>I'm happy.
<jackhill>Pattern mathcing question: Using this match '(match '(quote ("a" "b" "c")) ((quote (a _ c) ...) (list a c)))' results in (("a") ("c")).
<jackhill>Instead, I would like the rusult ("a" "c"). What do I need to change? I feel like I'm missing something about how quoting or pattern matching work (or both!)
<jackhill>Aha! I get it: (match '(quote ("a" "b" "c") (d e f)) ((quote (a _ c) _ ...) (list a c))) is what I want
<jackhill>I think :)
<daviid>this is not allowed in 3.0.6 anymore - (define (foo bar) (lambda ( . args) (apply + args))) - just a tiny example to illustrate a similar, though 'real' and quite more complex 'need' in g-golf ...
<daviid>wingo: ^^
<daviid>ah, i need to change the call for (define (foo bar) (lambda args (apply + args))), sorry for the noise ...
<daviid>wingo: quick feedback - commit 19f38a3 fixes the example given in #47084, as you probably did try, but here is a mini session https://paste.debian.net/1195743/
<daviid>wingo: however, it does not solve the 'Fwiw: (a)', that is, the public interface of a module that has been 'module-used', in 3.0.6 (unlike 2.2) may not evolve in time (at the 'essence' of any GI dynamic binding)
<daviid>here is a concrete example
<daviid>wingo: here https://paste.debian.net/1195745/
<daviid>this is to give you a quick feedback, it needs g-golf, but i will produce an example that does not depend on g-golf ... shall i answer #47084, or do you prefer to close it and reopen a more specific bug report for this ... lmk
<flatwhatson>Is this a sensible thing to do:
<flatwhatson>(define* (bytevector-slice bv start #:optional (count (- (bytevector-length bv) start)))
<flatwhatson> "Return a bytevector referencing COUNT bytes of BV from index START."
<flatwhatson> (pointer->bytevector (bytevector->pointer bv) count start))
<flatwhatson>To avoid unnecessary copying of subsets of bytevectors?
<flatwhatson>Will the gc get confused if this is my only live reference to that buffer?
<manumanumanu>stis: hej!
<manumanumanu>flatwhatson: good question. You could probably try it in a repl...
<stis>manumanumanu: tjena!
<manumanumanu>flatwhatson: so, I created a bytevector, went through the pointer->bytevector dance, made sure the original bytevector wasn't reachable. generated a lot of garbage, ran the GC a couple of times. No use after free, at least :)
<manumanumanu>Whether it is more efficient than a copy is another matter.
<manumanumanu>stis: are there any problems with python-on-guile for 3.0.5?
<manumanumanu>I am getting weird errors with the guix packages
<stis>I think so, i'm on bleeding edge guile and needed to modify python on guile
<stis>manumanumanu: : ^^
<manumanumanu>ah, ok.
<manumanumanu>Even so, I am getting some things running
<stis>ok cool
<manumanumanu>I am looking forward to seeing if I can help with the for macros! How would you go about getting the scheme output of a file?
<manumanumanu>compiling a .py -> .scm
<stis>ther is a python script ...
<stis>python file.py
<stis>should copile and run file.py
<stis>then there is an output file in log.txt
<stis>where you can find output code and for example clip int into a guile sesion and expand the macros
<stis>then you can try spot errors
<manumanumanu>great!
<manumanumanu>haha, the guix package shadows my python installation
<manumanumanu>nothing died yet!
***zap1 is now known as zzappie
<stis>yea we should so something about that
<stis>I use python for python on guile and python3 for Cpython3
<manumanumanu>Just to non-humble-brag: I feel like a king! I have managed to morph something spiritually based on andy's fectors into something that just passed the first RRB-tree test! I can now drop elements in amortizied O(1) instead of O(n) like regular fectors. Next up is O(logN) concatenation and insertion :D
<manumanumanu>not only that, as long as you have done no splits or concatenations, these extra features have no cost
<stis>lovely
<allana>Hi Guile. I'm quite new to scheme and I am trying to learn some things here and there. I have a question, is this idiomatic scheme? https://paste.debian.net/1195759/
<stis>allana: as a guile scheme itis ok I think!
<stis>be careful with define though
<stis>(define n (f n)) is not the same as (let ((n (f n))) ...) i think
<stis>that's bitten me a couple of times
<stis>in this case do not reuse n or use let
<allana>stis: thanks
<taw10>Might be able to make it a bit more succinct sing call-with-port?
<manumanumanu>allana: I would probably have use let* instead of (let (...) (define ...)) in that case. And the variable _ is generally not something I would use like that. I is mostly used as a marker for "ignore this" in macros and such
<taw10>using*
<manumanumanu>isn't call-with-port very new? How bout (with-input-from-file ...)?
<allana>manumanumanu: Thanks, this looks like what I would have liked to use. Coming from Python with-input-from-file sounds very familiar.
<allana>I'm mostly just poking around here and there in my free time. Thanks everyone!
<manumanumanu>allana: the ports system is something that takes some getting used to. (with-input-from-file path body ...) will bind (current-input-port) to the port pointing to the file at path. Any reading operation within "the dynamic extent" (meaning any code running in the body) that doesn't bother with changing (current-input-port) will read from the file
<manumanumanu>even functions called by functions called by the body in totally unrelated places. It just means "bind standard input to this file port for all the code in this code block".
<manumanumanu>allana: it is always nice to see people curious with scheme!
<allana>It's guix. I am bothered by the fact that I don't understand scheme well enough to fully customize my own machine. So now I am trying to learn guile/scheme and potentially start using it at work when it makes sense.
<leoprikler>allana: the python "with open()" statement is actually implemented as call-with-{input,output}-file
<allana>leoprikler: cool
<jlicht>I finally received my copy of "Software Design for Flexibility", anybody working through it in guile?
<davexunit>I got a working tree shaker prototype. in addition to including all of the modules in use, I had to also include a bunch of ice-9 source files that aren't modules that I wasn't expecting.
<davexunit>eval.scm, i18n.scm, posix.scm, psyntax-pp.scm, quasisyntax.scm, match.upstream.scm, networking.scm, r6rs-libraries.scm, and r7rs-libraries.scm
<davexunit>I guess there are still things I don't understand about how guile does things.
<civodul>davexunit: neat! that could be interesting for Guix too, for instance for the initrd
<davexunit>for instance, ice-9/match.scm is basically a shim and calls (include-from-path "ice-9/match.upstream.scm")
<civodul>(did you know? if you use Guix System, your initrd includes an elisp and an ecmascript frontend)
<davexunit>there is no associated .go file for this source file.
<davexunit>civodul: lol I have thought about this before
<civodul>ah yes, these can be hard to deal with
<davexunit>I wouldn't have expected the compiled module to need this source file
<davexunit>does the compiled file included the compiled version of match.upstream.scm?
<davexunit>I can't imagine we are evaling the pattern matcher every time we load it
<civodul>i don't know, it's weird that this file's needed
<civodul>i think we should be able to have configurations without source files, too
<davexunit>like binary only distribution? yes I agree
<civodul>yes, at least for cases where disk space matters (initrd, game jam, etc.)
<civodul>for match and other expansion-time modules, i'd also love to have R6-style phases
<davexunit>it's not a significant contributor to disk space in my case (3.9MB currently of 78MB) but it would be nice to slim down as much as possible.
<civodul>yeah
<davexunit>the compiled modules take up 37MB currently
<davexunit>but ditching the source would be nice
<davexunit>a more robust tree shaker would have to do static analysis to identify include-from-path calls, as well as @ and @@ usage.
<civodul>yeah
<davexunit>I got bit by an @ usage somewhere. it was in one of my own projects so I just changed the code to not use it.
<civodul>you can have a convention to not use it
<davexunit>buuuut if we had binary-only distribution we wouldn't need static analysis
<davexunit>for my own purposes I'm inclined to just live with these caveats.
<civodul>you still need to determine which .go files are needed?
<davexunit>civodul: yes, that *mostly* corresponds to which modules are loaded. except for ice-9, of course. ;)
<civodul>BTW, Guix has source-module-closure, which maybe is kinda similar to what you're doing?
<civodul>heh
<davexunit>I should check it out and compare
<davexunit>but here's another oddity with ice-9 that I don't yet understand.
<davexunit>there's posix.scm and posix.go, eval.scm and eval.go, but there's quasisyntax.scm but no quasisyntax.go
<davexunit>I had originally assumed that every .scm would have a corresponding .go but quasisyntax broke that assumption
<davexunit>I'm sure there's a reason but guile is a bit mysterious to me in its early boot state
<davexunit>but it's not a big deal to say "ice-9 is special" and add special accomodations for it since it's core stuff that everything needs.
<RhodiumToad>davexunit: some of the .scm files may be included into others rather than being a module unto themselves
<RhodiumToad>I noticed that with read.scm (which is just included into boot-9)
<davexunit>RhodiumToad: yes, that is what is happening.
<davexunit>I was just surprised that they were still needed when loading compiled modules
<davexunit>oops, somehow didn't notice that there was a libguile-3.0.a file hanging around. don't need that! that freed up 16MB right there.
<RhodiumToad>I guess that if x.scm includes y.scm, then checking whether x.go is current should check both .scm file dates
<RhodiumToad>(whether it does check or not I don't know)
<davexunit>yeah something like that. not sure the exact process.
<davexunit>my binary bundle is now 17MB compressed and 60MB uncompressed. big reduction from my initial version which was 29MB compressed and 120MB uncompressed.
<davexunit>need to stop now but this is promising. the tricky part is now turning this into a tool that can automate building the bundle. besides the tree shaking bit, I've been deleting files by hand to reach the minimal distribution.
<dsmith-work>Happy Friday, Guilers!!
<zzappie>hello!
<zzappie>Anyone has a clue in which situation (pk match) could ouput (<#syntax transfomer match>)??
<linas>breakpoints/repl shells deep in scheme code? How? Deep inside my code, I'd like to just get a repl, poke around, hit ctrl-D and have it resume processing where it left off ... how?
<linas>I guess I could do a recursive (eval (read)) or something like that ...
<linas>this gives a hint of what I want to do: (define (break)
<linas> (let ((input (read)))
<linas> (unless (eq? '. input)
<linas> (eval input (interaction-environment))
<linas> (break))))
<linas>(define (do-stuff)
<linas> (define x 42)
<linas> (format #t "start\n")
<linas> (break)
<linas> (format #t "end\n"))
<linas>If I run (do-stuff) and the enter (format #t "It is ~A\n" x) I expect to see "It is 42" but I get "unbound variable" instead...
<linas>ahh ,mabye I should use `local-eval` and `the-environment`? Hmm.
<rekado_>linas: you could start a REPL server
<rekado_>I like to use call-with-error-handling from (system repl error-handling) to spawn a REPL on errors
<linas>and then telnet into it?
<linas>It's not that I have errors, its that I'm deep in some nested map/fold/filter and want to stop and poke around and see what's been set in that environment. .. and then continue processing...
<linas>FYI, I was able to crete what I needed but it needed some elbow grease. I'ts below. I'm surprised this is not a standard guile utility that search engines latch onto ...
<linas>(define (break env)
<linas> (let ((input (readline "yo duude> ")))
<linas> (unless (or (eq? '. input) (eof-object? input))
<linas> (catch #t (lambda ()
<linas> (define sexpr (call-with-input-string input read))
<linas> (format #t "~A\n" (local-eval sexpr env)))
<linas> (lambda (key . args)
<linas> (format #t "Oh no, Mr. Bill: ~A ~A\n" key args)
<linas> *unspecified*))
<linas> (break env))))
<linas>(define (do-stuff)
<linas> (define x 42)
<linas> (format #t "start\n")
<linas> (define env (the-environment))
<linas> (break env)
<linas> (format #t "end\n"))
<linas>(define (bogo) (define y 56) (do-stuff))
<linas>with the above, both x and y at the prompt print the right thing.
<linas>and ctrl-D exits this pseudo-repl with execution resuming where it last left off.
<leoprikler>linas there are probably more elegant ways of spawning a repl, but yeah, that works
<linas>I'm a meatball coder. if there's some example web page or doc, tell me what search term to use
<leoprikler>I don't know how well it's documented, but there is start-repl and a repl server.
<linas>leoprikler the repl server is just a telnet server. It won't halt execution deep in the middle of some code, and let you poke around.
<leoprikler>that is correct, because the repl server is designed to run next to your code
<linas>(and worse, the guile repl server is crashy and slow; I have a super-whizzy telnet repl server that is super-fast and not crashy, and use that in production.)
<leoprikler>You might want to contribute your fast and not crashy telnet server to Guile at some point then :)
<linas>eh, its written in C++, with nasty ugly async i/o in it and a bunch of other weird custom stuff.
<linas>I could point you at it, but it would be a major chore to make it nice enough for ludo to not puke on it (its in github, opencog/cogserver repo)
<leoprikler>Hmm, I think for a purely guile-based repl-server there is a fiber variant, perhaps that works better?
<linas>right, I did hear about fibers; I have not tried them or anything built on them.
<linas>For generic repl, I cannot abandon the cogserver, since it needs to handle megabytes/second of s-expressions, most of which don't actually need to ever hit the guile evaluator. Like I said. it's weird. It also does python :-) for all the python lovers out there.
<zzappie>sneek: botsnack
<sneek>:)
<rekado_>I often wish match-lambda could deal with more than one argument
<rekado_>this would make fold + match-lambda possible, which is really nice for structured accumulators
<davexunit>rekado_: match-lambda* ?
<rekado_>… that exists?
*rekado_ checks
<davexunit>yup
<davexunit>(fold (match-lambda* ((n sum) (+ sum n))) 0 '(1 2 3))
<rekado_>poifect!
<rekado_>just what I wanted!
<rekado_>thank you
<davexunit>np
<rekado_>(has this only recently been documented…?)
<davexunit>yeah
<davexunit>when I learned about them they weren't mentioned in the manual
<davexunit>I just happened to be perusing the source