IRC channel logs
2023-09-12.log
back to list of logs
<civodul>i mean, that’s the name of the procedure that does that <civodul>in some cases i find ‘cut’ to be less readable than a plain lambda <graywolf>mirai: well yeah, I figured that much when I tried to run it; so the question was meant as: is there an elegant way to write this that actually works? I currently just rewrote it using (lambda (c) (eq? (channel-name c) 'guix)) which is not so bad. But I like cut (so far) as a way to create these short lambda functions, so I was curious if there is a better way. <haugh>graywolf, the predicate `guix-channel?' is defined in the module (guix channels), <haugh>civodul already answered this I'm just making sure it's unambiguous <haugh>If you're looking for a more general magic lambda syntax, none is provided by default, though Guile certainly provides the tools to write your own <haugh>I'm working on an anaphoric one that would allow you to nest the anaphors, unlike cut, but there are some serious tradeoffs that require real consideration <haugh>The vast majority of Guile code is written with the long-form lambda, though, so there might be some merit to just getting used to it <haugh>typing out l-a-m-b-d-a is a nice reminder that procedure creation isn't free :) <graywolf>I don't want to check that something is a channel, I want to filter out channel with channel-name 'guix out of %default-channels <graywolf>C-M-S-s-l for lambda also works I guess :D <haugh>(filter (negate guix-channel?) %default-channels) <graywolf>Oh, guix-channel? checks for 'guix channel, not for a record type <haugh>oh, filter is in guile core, not SRFI-1. excuse me <graywolf>(remove guix-channel? %default-channels) is what I will go with <daviid>gnome irc channels are dead - i can't find a descent matrix server, anyone uses/knows one that respect privacy? the fsf has none, unfortunately, the fsfe has one but is member only ... tx <rlb>speak of the devil :) <rlb>I'm toying with the idea of eventually setting up "regular" guile A/B perf tests if I end up with something reasonable, but for now I'm just interested in seeing what the impact of the utf8 branch is. <rlb>haugh: the general approach may not be to scheme/guile taste, but if I understand what you're up to correctly clj has its own compact syntax precedent. See the "Anonymous function" point here: https://clojure.org/reference/reader#_dispatch It's handy, if not pretty. <rlb>(Though now that I (finally...) arranged to easily type a lambda character, guile wins over the clj's "fn"...) <dsmith>rlb, You know, typing l a m b d a is not that much harder than \ l a m b d a ... <dsmith>I've been using Fira Code lately. And lambda looks like λ <rlb>Yeah, but it saves some of the precious 80 columns ;) <rlb>...but to be clear, although I have used some lambda chars in the utf8 brnach, I'll happily replace them with "lambda" if that's preferred. I was somewhat just amused. <rdrg109>[Q] Newbie: How to call a function in a module that has not been exported? <daviid>rdrg109: look for @@ in the manual <daviid>rdrg109: in 6.18.2 Using Guile Modules <daviid>RhodiumToad: it occured to me that in debian testing, when a package is an alpha or beta release, they name it using the word, not just the a or b letter. i am going to switch to this naming convention as well for g-golf, so the next release would be 0.8.0-alpha-6 <rdrg109>daviid: Thanks, I'm currently using guix, I have used that syntax, but still I'm getting "unbound variable". Do you use Guix? Do you happen to know what is going on? <rdrg109>The function config->sxml is defined in gnu/home/services/fontutils.scm, but still when I use (@@ (gnu home services fontutils) config->sxml). I get "unbound variable". <daviid>rdrg109: config->sxml doesn't seem to be defined in (gnu home services fontutils) <daviid>ah, i don't use guix, was looking at a probably old clone i had ... <daviid>rdrg109: can you confirm that function is defind in your local guix (gnu home services fontutils) module: can you edit the file and verify it is in? <rdrg109>daviid: Thanks for the help. How to open that specific file? <daviid>you need to find where this file is installed on your system <rdrg109>I ran guix pull some days ago, so that why I sent you the link to the remote repo, but yes, there exists the possibility that I have an oudated version, so I want to know how to open the specific file that is being read when I use (use-modules (gnu home services fontutils)) <daviid>rdrg109: you need to find and edit and verify the file that is installed, which may differ from your local clone ... <daviid>rdrg109: just to convince you that, ime, this is your problem, not guile ... <iyzsong>rdrg109: the file path can be get from '(%search-load-path "gnu/home/services/fontutils")' <rdrg109>daviid: You are right. I am wrong. I straced "openat" syscalls from the process running Guix REPL just when I evaluate (use-modules (gnu home services fontutils)) and these are the files that are shown. http://0x0.st/Hf3S.log How come there is no "fontutils.scm"? <daviid>rdrg109: i don't have the time, nor the guix experience to really guide you, but i am sure #guix will come to the resscue ... my point is, i think the module is there, but not the version that internally defines config->scheme <rdrg109>daviid: No problem. Thanks for the help! :) <rdrg109>iyzsong: I evaluated the sexp that you mentioned and I got "/gnu/store/md0qwciqdz26hg51z9ym2rkym6w8bycq-guix-module-union/share/guile/site/3.0/gnu/home/services/fontutils.scm". I jumped to that file and it does define config->sxml. Such an strange situation. I really want to find the root cause of this problem. <iyzsong>rdrg109: config->sxml is not 'exported' (or use define-public), so it only usable in that scm file. <iyzsong>rdrg109: um, i could get it work after: (reload-module (resolve-module '(gnu home services fontutils))) <rlb>ecraven: benchmarks ran fine. Not critical, but make html didn't work because graph.scm appears to be missing. <rlb>(also, may well be a debian-specifc change, but fwiw debian has chezscheme at the moment, rather than chez-scheme) <ecraven>yea, graph.scm is a complete mess :-/ <ecraven>rlb: unfortunately every distribution names chez differently.. and it doesn't help that the default is `scheme', which conflicts with other implementations :-/ <rlb>Hah, I see. I suppose we could add a bunch of chez tests like you have for the guile guile3, etc., or if/when you end up making the html stuff public, suppose we could just have a CHEZ ?= there or something for overrides... <rlb>In any case, thanks for maintaining the project. I think I can just work with the csv. <RhodiumToad>daviid: fortunately, it looks like freebsd ports treats 0.8.0-alpha-6 the same as 0.8.0-a.6 when it comes to computing PORTVERSION (both are converted to 0.8.0.a.6) <ecraven>rlb: there should be an override for every scheme executable, look in ./bench <ecraven>you can set an env variable (probably CHEZ) <RhodiumToad>(changing version numbering schemes becomes a problem only when the computed PORTVERSION comes out to something that compares as smaller than a previous version, since then you have to add a PORTEPOCH) <iyzsong>rdrg109: the doc say @@ is for debugging and a last resort, maybe it's designed this way... <RhodiumToad>it's not intended for normal use precisely because it's reaching inside the module and grabbing its private parts, which obviously might change without notice <RhodiumToad>if I need a fold operation that will usually be able to stop early rather than always processing the whole list, is it significantly faster to write a fold-until kind of loop, compared to using say let/ec to abort out of the usual (fold) call? <pukkamustard>RhodiumToad: Not a direct answer to your question but checkout SRFI-171 Transducers. It allows fold operations that can stop early and is quite a bit of fun. <RhodiumToad>hm. is there a good way to use a transducer to run a given proc over every element and return the (or) of the result, _without_ stopping early? <RhodiumToad>can't use or as a reducer directly since it's syntax and not a function <dsmith>RhodiumToad, How about a simple `(lambda (a b) (or a b))` instead of `or` ? <ulfvonbelow>today I learned that close-port doesn't always close the underlying file descriptor in the presence of multiple threads <RhodiumToad>dsmith: the reducer has to deal with multiple arities, so it's a bit more complex than that, but that general idea works <mwette>I wonder if the optimizer would inline that `or' in some cases <dsmith>How about `(lambda args (or-map identity args))` <meoccarthyism>when breaking code in a single project into different modules, what's the normative way to load them? modify %load-path to include the current directory? start file? <dsmith>Or maybe ->bool instead of identity <rlb>ecraven: oh, I meant for the makefile so on debian I could "make CHEZ=chezscheme html" or something. <morenonatural>hey, y'all ... is there something like elisp's let-alist for guile? <RhodiumToad>you could implement it using defmacro obviously but it'd be kind of icky <dthompson>I don't know of anything but it looks like it could be implemented hygienically using syntax-case <morenonatural>I've been using `match` to destruct sexps, but it feels cumbersome using it for assoc lists <dthompson>match isn't a good fit because alists are unordered <morenonatural>dthompson: yes... but in other situations I find it very comfortable to use to destruct and assign valus <mwette>syntax-case expanding to something like ((lambda ,(car alist) body ...) ,(cdr alist)) <dthompson>that dot notation is not something you could carry over hygienically, afaik <dthompson>a much easier macro would be one where you declare which keys you are pulling out of the alist up front <dthompson>something like (let-alist foo-alist (bar baz) (+ bar baz) would be easy to implement <dthompson>of course, there's 3 ways to ref an alist. assoc-ref, assq-ref, and assv-ref. <dthompson>(define-syntax-rule (let-alist (alist key ...) body ...) (let ((key (assoc-ref alist 'key)) ...) body ...)) <dthompson>(let ((alist '((foo . 1) (bar . 2)))) (let-alist (alist foo bar) (+ foo bar))) <mwette>agree with dthompson's idea; mine would not work <RhodiumToad>should wrap it in another let to bind the alist value <RhodiumToad>(define-syntax-rule (with-assoc-vals alist (key ...) body body* ...) (let ((%alist alist)) (let ((key (assq-ref %alist 'key)) ...) body body* ...))) <dthompson>well morenonatural you have multiple macros to pick and choose from ;) <daviid>RhodiumToad: a bit late to the party but ime, it is (significantly) faster to loop until compared to use abort forms, such as ime catch exit ... back then i did measure, working on guile-cv, where performance is absolutely crutial, and switched all abort forms to use good old loop until ... but ymmv i guess, in guile-cv, users may compose 'heavy' im-* procedures, working on large images, that either abort or loop until ... one abort <daviid>form call, processing a small data structure, wouldn't make noticeable diff i guess ... <haugh>daviid, just to be clear, you're referring to escape continuations, wherein the continuation is not "reified"? <haugh>ACTION is also working on looping atm <ecraven>rlb: yea, many things are on the list (or rather have been for way too long, still no time to actually improve things much :-/) <rlb>morenonatural: I suspect I could adapt lokke's destructuring (full clj nested map/vector/list destructuring) for scheme if the community were interested, but I'd be hesitant unless there really was notable interest, and we could figure out reasonably broadly acceptable semantics. cf. https://clojure.org/guides/destructuring <rlb>ecraven: ok, well if I keep going, I might see about providing patches for some minor bits that might or might not be suitable.