IRC channel logs

2023-09-26.log

back to list of logs

<haugh>dthompson, big agreement on the (ice-9 format) format strings. They simply can't have Scheme's self-documenting property, so it's always a bit of a lurch to encounter them. I wonder if it's worth extending/replacing `format' to accept sexps? The path of least resistance is probably a macro which returns a format string.
<haugh>I do love the functionality in that lib, especially the many iteration tools
<haugh>I guess if you use an expression there, you also want to be able to thread your arguments in there instead of appending them...
<ieugen>@sarthalion: are you absolutely sure the system locale is scandinavian? and the program detects that?
<sarthalion>ieugen: I use en_US.utf8 as a locale which can handle scanfinavian characters
<lloda>if you want a sexpy format there's srfi-166. bjoli ported 159 to guile which is an earlier version of that iiuc
<lloda>(ice-9 format) is too messy to fix or build on
<lloda>well too messy to build on. Bugs can always be fixed
<mirai_>haugh: have you looked at SRFI-166?
<mirai_>woops, already mentioned above
<sneek>dsmith: Greetings!
<dsmith>!uptim
<dsmith>!uptime
<sneek>I've been faithfully serving for 10 days
<sneek>This system has been up 25 weeks, 2 days, 19 hours, 34 minutes
<dsmith>sneek, botsnack
<sneek>:)
<minima>hi, i know i can run a system command and get its output with `open-input-pipe'; i'd prefer to use `system*' though, as it sounds safer; is there any third alternative that is as convenient as the former and as safe as the latter?
<sneek>minima, you have 1 message!
<sneek>minima, antipode says: There's a report and patches about the ‘make authenticate’ thing and its documentation at https://issues.guix.gnu.org/57910#1
<dsmith>minima, there is also `pipeline`. Not near as convenient, but gives you full access to input, output, and all the PIDs
<minima>hey dsmith thanks! yeah, my main concern was to get something that behaves as `system*' (i.e. that expects a list of individual tokens) as opposed to `system' and the various pipe-based alternatives
<minima>with some "port massaging", i guess it might be possible to get the stdout of `system*' too
<minima>but i wondered if there might be anything quicker
<minima>oh, i see in the docs that the pipe-based procedures are also needed because they need to wait until the command finishes its execution
<minima>so, `system*' might actually not work here
<acrow>I'm on guix using guile -- where is the module (test utils)?
<acrow>nm
<dsmith>minima, Also, some progs don't produce much (or all?) output until stdin is closed. (Like sort for example). pipeline gives you two ports.
<dthompson>(system repl error-handling) has code that allows for the on-error handler to be an arbitrary procedure, but repl-option-set! only allows one of (debug backtrace report pass) :(
<dsmith>So it allows you to close the stdin of the prog.
<minima>dsmith: ah got it, thanks!
<minima>Unrelated... I have an s-exp like `(list key-0 (0 1) key-1 (1 2 3) ...)' and I want to add a value to a given position (or "path") e.g. under key-1 I want to have `(1 2 3 4)'
<minima>I can of course use a combination of find, filter, remove, ... but is there any more clever way to "pattern match" a given item and change it given its "path"?
<minima>or maybe i should be using a different data structure ahah
<minima>oh wait... https://www.gnu.org/software/guile/manual/html_node/Pattern-Matching.html seems to provide the exact example i think i need :)
<minima>oh wow, pretty mind blowing
<RhodiumToad>do you want to add it destructively or nondestructively?
<minima>destructively, i.e. modifying the matching element in place, if that was the q
<minima>oh well, let me rephrase that, even better if it's functional
<minima>maybe a `match-lambda'?
<minima>and a map?
<RhodiumToad>your example isn't clear, you don't indicate where the variation is
<RhodiumToad>is it a list of (key (vals...) key (vals...) ...) and you want to append to the values of a specified key?
<minima>RhodiumToad: yes, sorry, you're right; and while i'm making this clear in my mind, i realise i might just use a map...
<minima>yes, that's correct; the actual data structure is a list of records
<RhodiumToad>each "val" is a record?
<minima>no, it's a list of records (in my original example i used "key" as a shortcut for one of the record fields)
<minima>`(<rec-0> <rec-1> ...)'
<minima>and i want to mutate one of the records
<minima>i think i can use a map with a lambda that leaves the record as it is unless the record's name matches a certain value?
<RhodiumToad>sure
<RhodiumToad>or a for-each since you're mutating the value rather than copying it
<minima>brill, thanks, i'm going to try that (sorry it took me a while to explain things properly)
<haugh>thanks lloda and mirai, SRFI-166 is glorious, especially `fn' and `with' are impressive. It is missing the advanced number formatting that I love from (ice-9 format)
<haugh>only just skimmed it; perhaps it's extensible
<haugh>I don't think (ice-9 format) has anything like numeric/si though
<haugh>To be more specific, I wonder if I can implement format:num->cardinal999 in terms of SRFI-166 `fn' and `with'