IRC channel logs

2025-10-19.log

back to list of logs

<euouae>How can I output into Tree-IL but retain source metadata?
<euouae>I've tried using `guild compile -O0 --to=tree-il foo.scm -o foo.tree-il` but I don't see any source metadata
<euouae>and by that I mean the `src` field
<euouae>I've also tried (compile '(...) #:to 'tree-il)
<resica>Hey daviid, you recommended to use the devel branch. Is there any gotchas in regards to API/ABI stability I should know beforehand?
<daviid>resica: no gotchas, the devel branch is 'as stable as the master' - I _never_ push untested and locally used code there ... it's just in case ... but quite safe to use
<resica>I wonder if the fact this is scheme or just the fact there are good maintainers for this is why I don't have this level of assurance with other bindings, like PyGObject.
<euouae>every project is different
<euouae>Does anyone know how Guile makes `read' available?
<euouae>I am looking at module/ice-9/read.scm, but it's not a module. How is it then becoming available?
<euouae>some magic at stage1 is all I can figure out
<old>euouae: look for `current-reader' perhaps
<euouae>old, while I didn't quite figure out how read becomes available, I did answer my XY question of where the source metadata goes when compiling to Tree-IL/CPS
<euouae>that was what I cared more about
<rlb>euouae: depending on what you mean, read is complicated -- there's (at least) the C reader and Andy's new pure scheme reader. The C reader's defined via scm_init_read in read.c iirc, and the scheme reader's in read.scm and is loaded I think via boot-9.scm -- see "include-from-path" in there.
<rlb>euouae: boot-9.scm is one of the key startup files that has to begin operation before even the module system is fully functional.
<rlb>And right, read.scm is "included" directly into the current module, which is I think is probably at that point the-root-module, i.e. (guile).
<rlb>s/which is/which/
<euouae>nice, thanks! I am writing a large blog post on debugging those segfault bugs and/or other bugs
<euouae>so I'm trying to add details on the whole source -> scheme -> tree-il -> cps -> bytecode process
<euouae>I feel that yet another source of info on the Guile internals wouldn't hurt
<euouae>that being said, I feel that the reader issue is closer to bootstrapping, and I don't want to touch that yet because I don't think it's as important for bug hunting those segfaults
<euouae>it's a different part of guile
<rlb>It's definitely complex, and I only know "bits".
<rlb>For srfi-207's reader changes, we needed a way to communicate between exceptions, srfi-207, and the reader, and the shared bindings needed to really "live" in (ice-9 exceptions), which can't be loaded at that point, so now we have a %boot-9-shared-internal-state hash table to handle the transition. Hopefully that'll also limit the need for any further pollution of the root namespace for that kind of thing.
<euouae>hm...
<euouae>so `guild compile --to=tree-il` won't save any source metadata, but `--to=bytecode` will; one can still compile to Tree-IL with source metadata using `read-syntax`, e.g. with (compile (with-input-from-file "/tmp/foo.scm" read-syntax) #:to 'tree-il)
<euouae>okay, apparently read-and-compile retains source metadata for all targets
<euouae>there's references to "open-coding" in the manual w.r.t. compilation, does that mean "inlining"?
<euouae>nevermind, it's explained at the end • Open-coding (turning toplevel-refs into primitive-refs, and call to primitives to primcalls)
<dpk>rlb: i’m curious what made SRFI 207 so complex in that regard
<rlb>dpk: nothing too exciting --- just needed &message, &irritants, &butestring-error, etc. before loading read.scm and before we could load (ice-9 exceptions): https://codeberg.org/guile/guile/src/branch/main/module/ice-9/boot-9.scm#L1571-L1589 Chatted with Andy about it and he seemed to think that the hash table was plausible for now (was a bit surprised -- had assumed it was probably too much a hack).
<meaty>hello guile
<meaty>does there exist a particular grammar for expressing key bindings/keypresses in scheme?
<meaty>or at least some prior art?
<dsmith>meaty, Like for readline? Or for a gui app?
<dsmith>I've never messed with it, but I think readline a some kind of config file where you can adjust bindings
<dsmith>If for some kind of gui thing, that probably within it's context, like X11, gtk, Qt, whatever and not Guile directly
<mwette>meaty: maybe dig into this: https://www.nongnu.org/emacsy/manual/emacsy.html
<euouae>Hello
<mwette>euouae: Good to see you digging into the guile compiler. Looking to see what insights you acquire. Over the last year or so I was updating my compiler tools to propagate source properties (e.g., using cons-source). I have not dug into the read-syntax update much.
<euouae>your compiler tools?
<euouae>Outside of Guile? I find that interesting :P
<mwette>in https://github.com/mwette/nyacc/tree/main, modules/nyacc/lang/c99/, examples/language/nx-{javascript,mlang,tsh,tcl}
<mwette>mach.scm has the grammer in all, the examples ones include compile-tree-il.scm files
<euouae>is this a parser generator or an ffi generator?
<euouae>oh it's a pasrer generator
<euouae>you added a lot of languages with ,L
<euouae>that's very cool
<mwette>I wanted to work parsers. Someone asked for C parser, so I created that. Then it made sense to try an automatic dot-h to wrapper generate (aka the ffi-helper). That's in there, too.
<mwette>thanks btw
<meaty>what's the right construct if I want to run procedures on list elements that may or may not be there? right now I'm doing a case statement where the key is the list length, but this leads to code repetition. also debpaste won't let me paste
<identity>«may not be there»?
<meaty>identity: I'm writing a type predicate where a type may have one, two, or three elements. If the second or third elements are there, they must match their own predicates
<meaty>the tricky part is that if you try to reference an element that isn't there you get an error. I'm sure there is some 'error->#f' procedure but that seems inelegant
<kjartano`>meaty: I would probably do something with a match statement.
<identity>(and (predicate type) (cdr type) (predicate1 (cdr type)) …) ?
<identity>‘pcase’ should also work
<meaty>identity: where is 'pcase'?
<identity>oh, i thought i was in a different channel
<identity>you want ‘match’ from (ice-9 match) instead
<meaty>word
<kjartano`>(match x
<kjartano`> ((one) (pred1? one))
<kjartano`> ((one two) (and (pred1? one)
<kjartano`> (pred2? two)))
<kjartano`> ((one two three) (and (pred1? one)
<kjartano`> (pred2? two)
<kjartano`> (pred3? three))))
<kjartano`>You could try something like this.
<identity>do not paste multiple lines in the chat, please
<meaty>kjartano`: then I end up with the same situation as the case statement
<identity>you could also do inline predicate checking with match, something like (match x (((? predicate1? one) (? predicate2? one)) #true))
<identity>s/2? one/2? two/ you get the point
<meaty>I see
<euouae>you can do (((? pred1? one) (? pred2? two) (? pred3? three)) ...)
<mwette>You should also look at case-lambda.