IRC channel logs


back to list of logs

<Sheilong>What module shall I import to be able to use "with-exception-handler"? I can't find it on the documentation
<robin>Sheilong, no explicit import needed in most cases, as it's in the (guile) module
<Sheilong>robin: I just figured out.
<Sheilong> (rnrs exceptions)
<Sheilong>before that it was complaining about unbound variable to with-exception-handler.
<Sheilong>I am trying an example from the documentation but <stdin>:4172:2: warning: possibly wrong number of arguments to `with-exception-handler'.
<Sheilong>I have a procedure which calls the error procedure when something go wrong. Now I need another procedure to handle this error when it happens and yields false.
<RhodiumToad>how did you call with-exception-handler?
<RhodiumToad>oh, also do you know about false-if-exception
<RhodiumToad>oh, and bear in mind that guile 2.x has two (?) different exception systems, which are unified in guile 3
<Sheilong>I am using 2.2.3. I didn't know about false-if-excepetion
<RhodiumToad>I don't know if it exists in 2.2
<RhodiumToad>ah, yes it does
<Sheilong>RhodiumToad: thanks so much. It was exactly what I was looking for.
<chrislck>sneek: botsnack
<taw10>Are there some "gotchas" around using parameters within eval? The manual says "XXX - dynamic states" (
<taw10>Inside my eval-ed code, I'm trying to use a macro which wraps things in 'parameterize' (i.e. the dynamic state starts WITHIN the eval'ed code). The eval'd code calls procedures from my "real" (non-eval'd) code, which need to access the parameter. But I get an unbound variable error
<taw10>Strange, because another part of the code uses the exact same pattern. I must have messed something up
<lilyp>Perhaps there's something wrong with your code staging
<lilyp>Where exactly are the bindings introduced and which side is supposed to use them?
<taw10>Oh, how embarassing. I forgot to define the parameter in the first place!
<taw10>I'd taken a break from Guile and evidently forgotten that the bindings don't just come from nowhere by "magic"
<lilyp>programming in Emacs Lisp be like
<Zelphir>@lampilelo: Thanks again for the hint with transforming an alist to a list of keywords and values and applying a keyword procedure to it. This seems to work nicely. It gets a bit hairy, when one does not want the keywords to be the same as the symbols, for example if one wants a keyword like `id` but the symbol is `id-attribute` stemming from the PEG parsing grammar, but that is something I will have to decide at some point. It couples the grammar
<Zelphir>with the names of the keywords of that procedure, but I think that's OK.
<Zelphir>I have one general question, which I am asking myself many times: Why is `rest` not in SRFI 1, but `first` is? And do people define `rest` in each their modules for example `(define rest cdr)` or do they simply use `cdr` and mix `first` with usage of `cdr`?
<Zelphir>I personally feel like I don't want to mix `cdr` with usage of `first`. I would rather use `first` and `rest` xor `car` and `cdr`.
<lilyp>I think people would rather use take+drop than first+rest
<lilyp>(drop list 1) ~= cdr
<lilyp>also if you're dealing with first . rest decomposition, using pattern matching is probably advantageous too
<Zelphir>Will need to think about that. Perhaps I have not been using srfi 1 as it is used by most.
<Zelphir>Usually happens, when I write some list eater like procedure.
<Zelphir>But indeed drop seems like an option.
<lilyp>first, second, third ... seem to be defined solely as convenient accessors for the nth elements
<lilyp>e.g. you have some table and you want to get the second column or stuff like that
<Zelphir>So instead of `first` and `drop`, I could do pattern matching. Would that impact performance a lot?
<Zelphir>Or would pattern matching fallback to being car/first anyway?
<lilyp>pattern matching would probably be more efficient than first, second and third, but probably about as efficient as car+cdr
<lilyp>Never forget that Guile has a compiler :)
<Zelphir>Ah, I somehow always thought that pattern matching would be way more overhead, because of how much fancy matching it can do.
<lilyp>it's all static tho
<Zelphir>So, when I pattern match against a list thing, it could probably know that and translate into a `car`. Whether it does, I have no idea.
<Zelphir>Ah well, in my case/project/program , I think performance on that level does not play a big role anyway.
<lilyp>So the important observations to make here are:
<lilyp>car+cdr becomes a function call rather than immediate unpacking
<lilyp>error handling is a little more expensive in the match case
<Zelphir>I am not sure how to read that disassembly, tbh. Not sure what I am looking at and don't know some of the terms there. But how did you get the disassembly?
<lilyp>guild disassemble
<lampilelo>i don't think many people use `first` as a replacement for `car`
<Zelphir>Is there some documentation page, which explains the various instructions, which could appear in such a disassembled code?
<lampilelo>what's wrong with car and cdr?
<Zelphir>`car` and `cdr` feel a bit "unreadable" as they are not saying "the first thing in the list" or "everything but the first thing".
<lilyp>it's an obscure reference to old hardware
<lampilelo>(info "(guile) Instruction Set")
<lilyp>OTOH: cadadr exists and after understanding car and cdr everyone knows what it does
<Zelphir>`(info "(guile) Instruction Set")` returns an error, if I run it. Is it not meant to be code?
<lilyp>it's shell code
<lampilelo>it's an elisp code, if you're not using emacs just paste it into the shell, without the outside parens
<lilyp>you might need to istall gash
<Zelphir>Thanks, got it. I ran it in geiser.
<Zelphir>In shell it works with or without parens (subshell).
<lampilelo>ah, right
<lampilelo>in emacs you'd M-: (info "(guile) Instruction Set") RET
<Zelphir>I see, might offer better browsability than in plain terminal.
<Zelphir>My Emacs seems to use a weird character (or font) for the "N" of " sN" on the first page.
<Zelphir>like a super-serif N, that looks almost like a square with a diagonal line in it ^^
<Zelphir>OK, anyway thanks for all the input! Need to reconsider my usage of `first` and think more about pattern matching, I guess. Haven't made use of it that much yet.
<lampilelo>Zelphir: i have an advice on how to use documentation for guile in emacs: put this in your init file:
<lampilelo>and then you'll be able to use info-lookup-symbol and search the documentation from your scheme buffer
<lampilelo>if you're new to info, i'd advice to read (info "(info) Top")
<Zelphir>huh, neat.
<lampilelo>imo the most useful key binding in info is `i`, but it's best to learn or at least check out all of them
<lampilelo>`l` and `r` to go back and forwards through history
<lampilelo>also info-lookup-symbol is by default bound to C-h S
<Zelphir>Is `info` using `texinfo` files?
<lampilelo>yes, it's a standard for documentation for gnu projects
<Zelphir>At some point I probably should look into that. Even if only to be able to contribute to documentation of projects.
<Zelphir>Heavily procrastinating on that, since it is connected to tex and that always has that taste of not so clean for me.
<Zelphir>But I think the point of texinfo is to abstract most of that away and make it simpler to write stuff in it.
<lampilelo>as a side-note: info-lookup-symbol works in many programming modes, e.g. C, perl, shell, elisp, etc.
<Zelphir>So basically the init file elisp code you linked is for telling info-look how to find the symbol. Telling it to look in the pages that are in :doc-spec – correct?
<lampilelo>yeah, you don't need to know tex to write texinfo
<Zelphir>I've only meddled with tex stuff for making nice PDFs using Pandoc and stuff, but it has always been an activity of trial and error and long build times and searching online, whether anyone already did what I want.
<Zelphir>For thesis I used it as well. Wrote the thesis in rst and then used Pandoc to translate to tex using a Pandoc template, but not before I parsed the document and changed things to get document internal links and quotes working correctly.
<Zelphir>The output is nice, but oh the language.
<lampilelo>:doc-spec describes the pages where info-look can find and how to parse the index of symbols for the specified mode
<Zelphir>It seems to work well, thank you for that.
<lampilelo>you can find what's already defined by looking up the info-lookup-alist variable
<Zelphir>Docs of some languages might be already in there by default, I guess.
<Zelphir>So far I have relied on a Geiser REPL running and displaying stuff in the minibuffer or searching in the Guile reference manual.
<lampilelo>i wish gnu stdc++ documentation was in info format
<lampilelo>but info has trouble with :: since it's used in the markup
<lilyp>couldn't you wrap those in asis tho?
<lampilelo>iirc you can't make a node with :: in the name
<lilyp>what about asis{::} tho?
<avp>apteryx: Hi! I replied to your Guile-SSH issue (#29) on GitHub.
<avp>(If that was you, I'm not sure though.)
<lilyp>ah, it's the info side that fails, not the texi one
<lilyp>sad info is sad
<lampilelo>lilyp: i don't really remember what was it all about, maybe i'm wrong and it is possible
<lilyp>nah, I've tested and it seems weird tbh
<lilyp>you could work around it by translating those ::s to underlines tho
<lampilelo>i know it was discussed on texinfo maling lists but iirc nothing came out of it
<lampilelo>hmm, seems like they implemented quoting mechanism for index entries and it works in standalone info, but never got into emacs' info-mode
<sneek>I've been running for 12 days
<sneek>This system has been up 13 weeks, 4 days, 5 hours, 49 minutes