IRC channel logs

2021-08-12.log

back to list of logs

<jgart>Hi Guilers, what does dflt mean in the context of the make-fluid procedure? https://www.gnu.org/software/guile/manual/html_node/Fluids-and-Dynamic-States.html#:~:text=A%20fluid%20is%20a%20variable,fluid%20to%20a%20particular%20value.
<jgart>The doc string gives
<jgart>> Return a newly created fluid, whose initial value is DFLT...
<vijaymarupudi>fluids represent values, and are initialized to #f
<vijaymarupudi>dflt stands for default, which represents the value it will otherwise be initialized to if you provide it
<jgart>ah default ;) haha silly me
<jgart>thnx!
<vijaymarupudi>You're welcome!
<jgart>maybe that should be changed to default instead of dflt to avoid confusion for others giving it a quick read
<jgart>I can send a patch if it makes sense
<jgart>I don't think dflt is standard
<jgart>I thought it meant something more technical than default
<jgart>like some acronym or something
<vijaymarupudi>I would support that change
<jgart>I think it would only help new readers of the docs
<jgart>I'll send a patch tonight
<daviid>vijaymarupudi: i won't change these small and script examples, because when the process is exiting, memory will be freed when the address space is destroyed - see https://devblogs.microsoft.com/oldnewthing/20120105-00/?p=8683
<daviid>sneek: later tell vijaymarupudi '... Stop wasting time and just exit alread.'- you should, however, keep track and unref instances if your app 'consumes' and 'releases' many instances while running ...
<sneek>Got it.
<vijaymarupudi>daviid: While I acknowledge that cleanup is not necessary for simple examples, that was where I expected this kind of information to be presented, that I would have to cleanup
<sneek>vijaymarupudi, you have 1 message!
<sneek>vijaymarupudi, daviid says: '... Stop wasting time and just exit alread.'- you should, however, keep track and unref instances if your app 'consumes' and 'releases' many instances while running ...
<vijaymarupudi>daviid: Besides, I feel one of the advantages of Scheme is that I don't have to think about cleanup too often, it's just cognitive load I'd rather not deal with. And I think with guardians and a gc-hook, it's possible to automate it in Guile!
<vijaymarupudi>Thanks sneek!
<vijaymarupudi>daviid: Thanks for answering my questions!
<jgart>can anybody recommend some high level async library for guile 3.0?
<jgart>something that doesn't require creating sockets at a lower level
<jgart>is there such a thing currently for guile 3.0?
<daviid>jgart: guile-asu
<daviid>sorry
<daviid>guile-async
<daviid>sneek: guile-software?
<sneek>From what I understand, guile-software is http://sph.mn/foreign/guile-software.html
<daviid>jgart: ^^ listed there ...
<daviid>among others ...
<jgart>Ohh ok, this one https://github.com/ChrisVine/guile-a-sync
<jgart>actually this one for guile 3.0 https://github.com/ChrisVine/guile-a-sync3
<jgart>thanks!
<daviid>yes
<jgart>I'll take a look
<jgart>daviid, have you used it before?
<jgart>do happen to know if it's production ready more or less?
<daviid>no, i perso didn't, but imo very production ready, and fwiw, it uses g-golf for the version that offers the event loop based on GLib ...
<daviid>jgart: which you don't need (g-golf), unless you want to, guile-a-sync3 has other event loop(s)
<apteryx>is 'get-line' a blocking call?
<civodul>hey apteryx! it's blocking if the port is in blocking mode (which is the case by default)
<apteryx>Hello! oh, a non-blocking port. That's news to me, I'll read on it; thank you!
<civodul>in short, non-blocking i/o is not very useful if you don't use it together with something like Fibers
<apteryx>hmm, I see. It's in the context of an event loop that is already using select on the file descriptors to know if there's something to read, so I guess I could do with blocking calls on the fds that are ready to read?
<apteryx>to be read*
<vijaymarupudi>One problem I see there is if there is no newline in the incoming stream, then get-line will block until there is one
<dsmith-work>{appropriate time} Greetings, Guilers
<civodul>apteryx: in that case you can select on that port and only call get-line on it when select told you there's data available to read
<apteryx>OK. get-line would still block when there's no newline in the available data to read, as vijaymarupudi hinted at, right?
<vijaymarupudi> https://git.savannah.gnu.org/cgit/guile.git/tree/libguile/rdelim.c#n152 This suggests to me that it just reads until it's EOF or a newline
<apteryx>indeed; and scm_getc blocks when there's nothing to be read?
<civodul>apteryx: yes, correct
<apteryx>OK, thanks!
<muradm>hi guile
<muradm>today i had an issue which i couldn't get
<muradm>(define lst1 '(#f #t #f)) (apply or lst1)
<muradm>this does not works, apply can't apply or?
<muradm>(or #f #t #f) works
<ft>‘or’ can't be implemented as a function, since it has different semantics (short-circuit), so you can't hand it to apply.
<ft>But you can use ‘any’ from srfi-1 to do something like that: (any identity lst1)
<muradm>is there anything that can be used in stead of (apply or lst1)? currently i came up with this, but it looks dirty https://paste.rs/m9c
<ft>Like I said, ‘any’ can do something like that.
<muradm>yeah, i see, anthing
<muradm>any ^^^ thanks
<muradm>perfect https://paste.rs/1BT
<muradm>even more https://paste.rs/zL9
<muradm>another question, (string-tokenize ...) takes token_set, there is no example and explaination is not clear what should go there, i want to split string on "\n" only
<apteryx>It seems like implementing a non-blocking get-line is non trivial? I'd have to use seek + peek-char (I think), and seek is lseek in my case (file descriptor) so the offsets are in bytes while I'm interested in characters. So I'd have to wrap my head around the encoding used and decode the raw data.
<apteryx>muradm: I think it takes a character set, so (char-set #\newline) if I'm not mistaken
<apteryx>oh, and you have to reverse the set
<ft>Maybe just string-split in that case.
<apteryx>muradm: ^ what ft said
<ft>But ftr, I've used string-tokenize here: https://github.com/ft/chip-remote/blob/master/scheme/chip-remote/protocol.scm#L33 — ‘protocol-char-set’ is defined at https://github.com/ft/chip-remote/blob/master/scheme/chip-remote/protocol.scm#L74
<muradm>(string-tokenize does trim also in one step, but (split-string then (map trim also possible, i will try both, thanks
<apteryx>for string-tokenize you'd have to use (char-set-complement (char-set #\newline))
<muradm>ah... string-tokenize trims only the token_set char, not as default call to trim
<muradm>(split-string them (map trim should be more clean
<muradm>is there something like "is list empty" or better "is list not empty"?
<apteryx>I guess for my "non-blocking" get-line, I'll just read-char, dump everything available to a string, keep the result in a global variable attached to the file descriptor and post-process it locally.
<apteryx>the goal is to have every line of a child process output prefixed by some information
<yoctocell>muradm: there is null? for checking if a list is empty
<muradm>thanks
<vijaymarupudi>apteryx: I don't think that's necessary
<vijaymarupudi>You can just search for the ascii newline byte in the bytevector read from a port
<vijaymarupudi>if there is one, combine with buffer contents and emit a line
<vijaymarupudi>If there is not one, add to the buffer, and then suspend until next read
<vijaymarupudi>You can do this because in utf-8, all multi-byte characters have a 1 in the highest bit of their bytes
<vijaymarupudi>Maybe you don't want to assume utf8
<atka>hi guile, how do I use ice-9 debug?
<atka>or how do I activate it?
<atka>I don't have debug.scm listed in .guix-profile/share/guile/3.0/ice-9/
<atka>ok, looks like I can just use ,trace