IRC channel logs

2023-02-24.log

back to list of logs

<cow_2001>(pretty-print (macroexpand '(some-stuff-here))) does not pretty print the tree-il. the tree-il is a single object displayed in a #<…>
<cow_2001>is there any way of pretty printing it?
<cow_2001>maybe converting the tree-il into a raw s-exp somehow?
<cow_2001>and then pretty printing that?
<cow_2001>i am out of my depth
<flatwhatson>cow_2001: (use-modules (language tree-il)) (pretty-print (unparse-tree-il (macroexpand '(some-stuff-here))))
<cow_2001>woah.
<cow_2001>flatwhatson: THANK YOU!
<flatwhatson>:)
<attila_lendvai>can someone please point me to an example where guile is used in a shebang line? i need a complex example that loads dependencies from modules. my problem is that (current-file) returns #f, and i cannot just add-to-load-path at the head of my script.
<attila_lendvai>another issue is that even though i have a valid -L entry, i still get a module not found error
<attila_lendvai>so, i cannot add a relative path to the guile load path neither from inside the script, nor using -L
<attila_lendvai>damn! it's due to something in my environment, because the script i have had for a long while also stopped working due to the same current-file issue...
<attila_lendvai>the issue seems to originate from adding two entries to GUILE_LOAD_PATH external to the script. if i don't do that, then (current-filename) works. the entries look ok.
<chrislck>has here ever been an obfuscated lisp (or scheme) contest?
<chrislck>(let's not include easy tricks like using unicode symbols)
<attila_lendvai>i think that would be an endless rabbit hole if you can write code that is run at read time...
<attila_lendvai>i get a deprecation warning from fibers: https://github.com/wingo/fibers/blob/8f4ce08cd009926061d6ebfc55e4fa1e0b80ddd3/fibers.scm#L38
<attila_lendvai>can this be done better? i.e. by eliminating all references to the deprecated bit-count at expand time?
<attila_lendvai>reported as https://github.com/wingo/fibers/issues/79
<ArneBab>attila_lendvai: I have quite a few examples here: https://www.draketo.de/proj/py2guile/#sec-2-2-3-2-1
<attila_lendvai>ArneBab, excellent, thanks! saved in my notes.
<mwette>attila_lendvai: I think that's a dup of I think thats a dup of https://github.com/wingo/fibers/issues/66
<attila_lendvai>mwette, well, there was an attempt to fix it, but the warning is still there, because the reference is guarded by a runtime if
<mwette>ah - I'll take a look
<gtz>The exceptions in guile are a bit confusing and I don't see any examples here: https://www.gnu.org/software/guile/manual/html_node/Raising-and-Handling-Exceptions.html
<gtz>All I want to do is to catch an exception and ignore it. How do I do that? It looks like if I use with-exception-handler and raise-exception my exception handler is called but afterwards another exception is called and my program stops
<dthompson>gtz: I agree it's a bit confusing. I think you may want to use #:unwind? #t in with-exception-handler
<dthompson>the default is to *not* unwind, and if the exception is not continuable, which most aren't, and you do not escape the continuation somehow then you get that second error you mentioned.
<lloda>gtz: catch/throw is less flexible but simpler, you can try that
<lloda>also https://vijaymarupudi.com/blog/2022-02-13-error-handling-in-guile.html
<gtz>I think I will just use "guard"
<gtz>looks simpler
<gtz>maybe I just have a trouble calling raise-exception with continuable set to true
<gtz>what does this signature mean: raise-exception obj [#:continuable=#f] ?
<gtz>I found this https://www.gnu.org/software/guile/manual/html_node/Raising-and-Handling-Exceptions.html but I don't think it explains it clearly
<gtz>why don't they have examples, was it so hard to write 1-2 lines of examples?
<gtz>how do I call raise-exception with continuable set to true?
<gtz>sorry, I meant this: https://www.gnu.org/software/guile/manual/html_node/lambda_002a-and-define_002a.html
<gtz>ok there is a typo!!! instead of "continuable" the signature should have said "continuable?" that is all...
<lloda>good catch :D
<gtz>the only reason i found it is because in the description it says "continuable?"
<gtz>otherwise I wouldn't have a clue
<gtz>"If continuable? is true, the handler is invoked in tail position relative to the raise-exception call. " That means that the handler can call itself without consuming stack space, correct?
<lloda>that depends on how that call happens. All the text means is that there's nothing waiting for the handler to return
<lechner>daviid / Hi, in (htmlprag) can I modify %default-parent-constraints in order to parse 'HEAD requests, which have no body? https://paste.debian.net/1271957/
<dthompson>(with-exception-handler (lambda (e) 'ignore) (lambda () ...) #:unwind? #t) should do the trick
<lechner>dthompson / Hi, gnucode in #guix may need some help formatting code blocks in Haunt so that they show up like on your blog
<dthompson>lechner: oh thanks for letting me know! I'll follow up with them there.
<lechner>Hi, can Guile's parameters change just one item in an alist, as like ('body . #f) here http://git.savannah.nongnu.org/gitweb/?p=guile-lib.git;a=blob;f=src/htmlprag.scm;h=79a7b2f33b0755474bfc015912c01bdf6c676a15;hb=HEAD#l1119
<lechner>maybe that's more of a general #scheme question. i'll ask over there
<sneek>wb chrislck
<civodul>is anyone here (presumably a non-Guix person) using Guile 3.0 on top of libgc 8.2.2?
<civodul>i wonder if there are any gotchas we should be aware of
<civodul>ACTION pushed -Wunused-module
<lloda>apparently i'm on libgc 8.0.4
<civodul>ok, looks like newer releases weren't as popular as 8.0.4 :-)
<gnucode>dthompson: basically some people in #guix strongly encourage me to make my code snippets on my blog (gnucode.me) look more like yours. With some syntax highlighting for code snippets.
<dthompson>gnucode: ah, okay. I can point you to how I do that. I post-process my markdown posts to add the highlighting and other stuff.
<dthompson> https://git.dthompson.us/blog.git/tree/markdown.scm#n46
<dthompson> https://git.dthompson.us/blog.git/tree/highlight.scm
<ekaitz>gnucode: I don't know what dthompson uses for that but prism.js is an interesting option
<ekaitz>dthompson: how does that play with screen readers?
<dthompson>ekaitz: I don't know but all it does is add css classes so I'd guess it wouldn't be an issue
<gnucode>dthompson thanks for the tips. I'm pretty sure you've told me how to do this before... I'll try to actually go and do it this time. :)
<ekaitz>dthompson: yeah, it shouldn't!
<dthompson>gnucode: good luck. hope the code is clear! feel free to ask questions
<gnucode>dthompson thanks. How's the goblins work coming?
<dthompson>gnucode: going well! working on a debugger for it and also doing some guix stuff for the guile wasm project.
<gnucode>that's awesome!
<dthompson>:)
<old>hey I need to quickly be able to generate C files. I would like to use Guile as a template language like Mako in Python
<old>I know that there's autogen that has guile stuff in it. But anything easier?
<old>right now I'm just doing dumb stuff with format
<mwette>old: nyacc has a C pretty-printer, from SXML trees: https://git.savannah.nongnu.org/cgit/nyacc.git/tree/module/nyacc/lang/c99/pprint.scm#n113
<mwette>and a parser too, if you want to get used to the element names in the sxml
<mwette>I believe janneke uses the c pretty printer in his guix bootstrapper
<old>Right. I'm not sure if that's overkill. It does not have to be a 'C' solution. Any template language would do
<old>So I can write fix body in the natural language of C for example and do stuff like: {{(call-some-scheme-and-echo-here)}}
<old>autogen does exactly that, maybe I could try it again
<mwette>Not sure what you want to do. w/ nyacc, you could parse an existing C file, insert sxml in the middle of it, then print it out. Most comments will travel through.
<old>hmm I see
<lilyp>Real programmers use m4.
<manumanumanu>lilyp: outside autotools, where is m4 used?
<lilyp>I could tell you a project but then I'd have to kill you.
<morganw>manumanumanu: I guess anything could choose to use it as a preprocessor, e.g. https://www.ctwm.org/manpage.html#_m4_preprocessing
<manumanumanu>Oh, I have used it. But outside my use and autotools I have never seen it anywhere.
<morganw>I've used it to generate YAML files for GitHub Actions, if that counts.
<mwette>i love m4
<old>m4 gives me nightmare
<old>I will make a simple template transformer in Guile. Very simple to do
<old>just wanted to know if it actually exist before
<daviid>lechner: wrt guile-lib, any modules, please ask for help without 'quoting' me personnaly
<daviid>lechner: although i indeed maintain the package, it is 'has been so far' an admin role - i did not write and do not know well any of the guile-lib modules - wrt htmlprag in particular, we have a few htmlprag experts here, quoting me might have the undesired side effect to 'inhibit' their capacity and wishes to answer ...
<daviid>lechner: wrt to your parameter question, 'how can one change a parameter using guile', (as you've been told in #scheme i think) by calling parameterize, see the doc ... now if that will solve your htmlprag quiz, i don't know