IRC channel logs

2020-07-09.log

back to list of logs

***catonano_ is now known as catonano
***wxie1 is now known as wxie
<minerjoe>I'm loving guile. New to scheme, old time C and Common Lisp. Thanks to all you.
***apteryx is now known as Guest45514
***apteryx_ is now known as apteryx
<manumanumanu>leoprikler: more like (match black-box ((my-own-pattern-matcher key val) val) ...) I doubt I will make it optimize 2nd hand pattern matchers, but lists, vectors, streams and such will all be matched. I could probably even make one for generators, given I can (gcons ...) them back on again.
<manumanumanu>whereas you with ice-9 match is limited to whatever it supports. Which takes you all the way there, always, but it would still be neat to have. Say custom matching for a goops class
<leoprikler>I don't think that'll work, because pattern matching is basically syntactic sugar
<manumanumanu>leoprikler it works already. I can query a binding in a module and get it's value, and if that value happens to be a macro expander I can use that to make my matcher modular
<manumanumanu>I could also do the simple thing. Register the syntax object of the name of, say, (define-matcher my-matcher ...) and check whether a matcher used points to the same thing on the syntax level.
<manumanumanu>I would guess racket does one of those above (probably the first one, since matchers are represented as structs and you have to work with them programmatically to actually get any meaningful thing out of them
<leoprikler>hmm, that sounds a bit like how (ice-9 regex) works to me
<leoprikler>If you use records to store information you can have functions instead of macros
<manumanumanu>well... I _want_ the resulting code to be fully expanded. I just query whether (@@ (module module) name) is an instance of the record <pattern-matcher>
<manumanumanu>if it is, I use the macro expander stored in the record to expand to whatever it expands
<manumanumanu>that means, however, that the syntax will be more verbose: (ice-9 match) matches lists like (a b c), whereas my expander (and iirc racket's) will use (list a b c)
<leoprikler>hmm, perhaps you could try with a variant of ice-9's matcher that allows invoking custom macros
<leoprikler>e.g. binding the special symbol => to your magic
<leoprikler>that way you can have list matching as (a b c) and you can also have (=> my-matcher d e f)
<leoprikler>(by the way, is there a reason why ? is not enough)
<manumanumanu>leoprikler: I don't want to invoke anything in the patterns. Everything that is not a matcher should be either a literal (to be tested with equal?) or an identifier to be bound or an ignoring _.
<roelj>Hm, how can I capture the stderr from an open-input-pipe? I tried wrapping (with-error-to-port (open-output-string) ...) around it, but the stderr of my terminal is used instead..
<manumanumanu>roelj: i don't know of any way :( Even the open-process (on which open-input-pipe is built) only provides stdin and stdout iirc
<manumanumanu>you could write your open-process using fork
<manumanumanu>that is gnarly by the standards of people not used to C, though
<roelj>Well thanks for the bad news :)
<manumanumanu>we should really have an even lower level way than the hacky (@@ (ice-9 popen) open-process). Racket's subprocess returns a stderr where supported iirc, so does chez
<roelj>I agree
<roelj>For now I'm going to try to implement it in C.
<roelj>Outside of Guile
<roelj>Hha, come to think of it. A hack would be to create a temporary file and append "2> that-temp-file", and then simply read from that file with Guile.
<roelj>.. so is there a facility in Guile to make a named pipe? (A pipe that I can write to as if it was a file)
<manumanumanu>roelj: like a fifo?
<manumanumanu>but a file
<roelj>(mknod ... 'fifo ...)?
<roelj>manumanumanu: Yes, exactly a fifo.
<manumanumanu>mknod
***sputny1 is now known as sputny
<manumanumanu>iirc
<manumanumanu>roelj: ^
<roelj>Ideally, can it be combined with tmpnam in a safe way?
<manumanumanu>that I can't answer though. i'd say probably not since I suspect it is just a wrapper around mkfifo
<roelj>thanks
<roelj>Sweet! Using "mkstemp!" and redirecting error output to (port-filename ...) I captured the stderr from "open-input-pipe". It'd be even better if I could instead use a FIFO, but I don't know how to retrieve the filename from (mknod ... 'fifo ...)..
<manumanumanu>good! nice to hear it worked out
<rekado>roelj: you provide the file name to mknod.
<roelj>rekado: Hm yes. How do I create a filename that I can safely pass to mknod?
<manumanumanu>roelj: randomly? :D Read 16 bytes from urandom and create a filename
<roelj>What does mknod do if the file already exists?
<manumanumanu>roelj: raises an exception
<roelj>Great
<manumanumanu>I don't know what exception (and I don't really know how to work with the new exception system).
<roelj>That can be found out quickly enough :)
<dsmith-work>Thursday Greetings, Guilers
***jonsger1 is now known as jonsger
***bchar_ is now known as bchar
<manumanumanu>roelj: did things work out for you?
<stis>how can a print a stack trace at will?
<justin_smith>stis: try (backtrace)
<stis>thanks
<mwette> But I think you need to create a stack object first; I had code but can't fidn it now
<justin_smith>stis: I didn't expect it to be that simple, I found it with (apropos "backtrace")
<mwette>maybe the stack thing is if you want to start a debug-repl "at will"
<stis>backtrace works perfectly, mucho thanks.
<justin_smith>correcting myself, I ran (apropos "trace")
<stis>that command was wonderful to put in my program, made the bug shallow.
<justin_smith>stis: the built in debugger is also helpful - it can do similar, without needing to change your code
<stis>I know but the bt is lost because of ctaching and throwing at multiple places
<stis>the original stack is hence lost when one does ,bt
<justin_smith>stis: oh yeah, and with TCO it gets even worse, good point