IRC channel logs

2020-12-28.log

back to list of logs

<chrislck>it's a strange state of affairs when C is slower than guile
<oni-on-ion>eh. ffi and whatever else in beween
<ryanprior>Y'all how do I accomplish a negative lookahead in Guile regex? I want a pattern that matches any string not ending in ".v"
<ryanprior>I tried ".*(?<!\\.v)" and it does not like that
<ryanprior>I actually tried it with two backslashes, and typed it into IRC that way, but I see it with a single backslash. So if you see only one, know that I typed two and that at least is not the problem.
<ryanprior>I want to list all files in a directory that don't end in ".v" - maybe there's an easier way than using regex to match the names, I'm open to anything :)
<daviid>ryanprior: here - https://notabug.org/guile-zstd/guile-zstd/src/master/guix.scm - line 26-35, you have a similar example (fwiw, written by one of our guile's maintainer)
<ryanprior>daviid: thank you, reading
<ryanprior>Okay so I think I can use a file-system-fold using string-suffix? on the file names.
<spk121>ryanprior: this is what I came up with https://paste.gnome.org/pcmapyosm
***karlosz_ is now known as karlosz
<ryanprior>Dang okay, that raises many questions. Is there much performance overhead in Guile for exception handling? In some dynamic languages it's quite resource-intensive because it captures all the information about the stack and turns it into a data structure etc
<spk121>of course, I should have used string-suffix, but, I couldn't remember the name of it
<ryanprior>Also is it expensive in Guile to reverse a very long string? Does it eagerly perform the O(n) computation or does it give you a lazy reverse iterator?
<spk121>string-reversal is probably not the way to go. I was just being lazy. string-suffix would be better
<ryanprior>Like I know in Ruby, filename.reverse.start_with? "v." would be constant-time
<ryanprior>I just like learning & knowing these internal things =D
<chrislck_>ryanprior: you'd do well to clone guile source code - it's very readable
<chrislck_>and if you can optimize things send a patch
<chrislck_> https://git.savannah.gnu.org/cgit/guile.git/tree/libguile/srfi-13.c#n2361
<ryanprior>Ah okay so it does eagerly reverse the string
<ryanprior>And copies it too
<ryanprior>One of the things that's made it hard for me to learn Guile is that a lot of crucial stuff is inside these SRFIs and I'm not good at figuring out which ones are relevant to what I want to learn
<ryanprior>I get the sense that a lot of Guile hackers must have a bunch of these SFRI numbers and ice-9 modules memorized
<chrislck_>^that's right
<ryanprior>I need to find (or build) a resource for Guile that's similar to clojuredocs.org & friends
<ryanprior>I've been using the Guile info manual and it's time consuming and often frustrating to try and search the manual to find functions I want
<ryanprior>And even when you do find the function you want, it doesn't have hyperlinks to the actual C source code so you have to go and hunt down where it's defined
<chrislck_>clone it and use ripgrep
<chrislck_>string-reverse! is good too
***sneek_ is now known as sneek
<ryanprior>I do use ripgrep, but if I search for something then I wade through the results to find the actual definition I want.
<ryanprior>Versus the docs for other languages I use, where finding that info takes seconds.
<ryanprior>It makes all the difference between staying in the flow and accomplishing tasks as I learn the language, or bogging down and using my mental resources navigating code instead of focusing on the problem at hand.
<Aurora_v_kosmose>Is Geiser not able to find a definition for a function typed in its REPL?
<Aurora_v_kosmose>It may be usable as an easy way to jump to functions.
<chrislck_>ripgrep in emacs makes it easy to jump to definition
<Aurora_v_kosmose>ripgrep requires you to pattern '(define (whatever-this-is-aname' rather than just M-.
<chrislck_>All I did was 'M-x rg' 'string-reverse' [ENTER] [ENTER], get results, C-x o, [down] to results, [ENTER]
<chrislck_>muscle memory
<Aurora_v_kosmose>In some cases of a popular function, you might get hundreds of matches with just that name.
<Aurora_v_kosmose>Though I suppose Guix is perhaps not the most typical of Guile projects in scope...
<tohoyn>sneek: botsnack
<sneek>:)
<leoprikler>ryanprior: If you think hard about it, memorizing SRFIs is not too different from memorizing std:: namespaces and their headers
<ArneBab>Aurora_v_kosmose: you could try dumb-jump which can use ripgrep as backend
<ArneBab>Aurora_v_kosmose: you might have to define the target source, though
<ArneBab>ryanprior: for ice-9 I do not have numbers memorized — that’s just the prefix to the guile-specific stuff. For SRFI’s I agree: For me it also took long to learn the relevant ones and I still have to go searching to see which one is relevant.
<ArneBab>Something like srfi-lookup which interactively narrows down to SRFIs would be pretty useful — also between implementations.
<Aurora_v_kosmose>ArneBab: Oh neat, I didn't know about that package.
<ArneBab>I use it for javascript development at work — it’s just as good as IntelliJ in finding definitions in Javascript-code :-)
<ArneBab>(which means it is not too shabby but not perfect — but fast enough for a large codebase)
***apteryx is now known as Guest33950
***apteryx_ is now known as apteryx
<ArneBab>ryanprior: to find SRFIs it would be cool to have something like org-rifle¹ — but specialized to SRFIs (and also copying and html->org-converting SRFIs² on-demand). ¹: https://github.com/alphapapa/org-rifle ²: https://srfi.schemers.org/srfi.tgz
***chrislck_ is now known as chrislck
<rekado>somebody didn’t check if a project with a certain name already existed: https://github.com/adam-mcdaniel/wisp
<justin_smith>if there's one thing a programmer loves, it's being the nth+1 person to make the same joke
<ane>is there a way to force some guile code enter the debugger we see in the repl?
<leoprikler>ane: what exactly do you mean by that? You can trigger the debugger by throwing an exception etc. but what are you trying to accomplish?
<ane>well, something like (break)
<ane>instead of having to call some code that's guaranteed to go boom
<rlb>Imagine this might be intentional, but when trying to write some syntaxes that introduced some recursive bindings, noticed that #nil has no syntax, i.e. (syntax 5) is fine but (syntax #nil) crashes. Is that intentional?
<rlb>This complicates things when (for example) trying to get the first form from a "body" to use via say (datum->syntax (car body) 'foo). i.e. that works unless the body was (#nil ...).
<leoprikler>ane: No direct solution, but have a look at (system vm traps)
<leoprikler>rlb: depending on what you work with, that might very well be.
<leoprikler>I suppose #nil is undefined outside of the Emacs bindings.
<rlb>Wonder if it'd be reasonable for it to behave like "everything else" there...
<leoprikler>what'd be "everything else" in this case?
<leoprikler>would "#(1 2 3)" be acceptable in that position?
<leoprikler>what about other custom reader syntax?
<leoprikler>I think you might be able to add #nil as a special case in the usally empty arglist after syntax-{case,rules}
<leoprikler>e.g. (syntax-rules (=> #nil) (...))
<rlb>I just meant that if (syntax #f) is valid, then perhaps (syntax #nil could be too).
<rlb>For what it's worth, the broader context was trying to figure out how to introduce an unhygenic binding for say 'foo to an arbitrary "exp ..." matched set of "body" expressions.
<rlb>i.e. foo should be in scope for those forms, and nothing else.
<leoprikler>An anaphoric macro?
<rlb>(and just randomly, this was in a context where #nil might appear, so I noticed, when #nil ended up being the thing pulled out of the body for the (datum->syntax ... 'foo) call.
<rlb>)
<rlb>"noticed the issue"
<rlb>yes, i.e. "break" for a loop, or...
<RhodiumToad>was there a good reason for the unhygenic binding, rather than a hygenic one or a syntax parameter?
<leoprikler>And the issue is specifically with #nil?
<leoprikler>In my personal experience, getting such macros to properly expand in the first place is not a trivial task.
<rlb>leoprikler: the problem was that given that "exp ..." body I was trying to use something from that body as the context/template argument for datum->syntax in order to establish the 'foo with the right scope. That works fine if you grab a symbol, etc. but nil crashes datum->syntax because it's not (and can't be) a syntax.
<rlb>But I suspect my approach may not be entirely sound to begin with.
<leoprikler>yeah, that sounds like an ugly hack
<rlb>I guess the fundamental question I had is, given an "arbitrary" syntax object, can I introduce a binding that's visible to everything in the object (i.e. wrap it in a let(rec) for that unhygenic binding, and if so, how -- i.e. where do I get a suitable context for datum->syntax.
<rlb>RhodiumToad: as an example, imagine trying to implement clojure's loop syntax: https://clojure.org/reference/special_forms#loop
<rlb>It's a much weaker form of our "let loop"
<rlb>and one where the only name available is 'recur
<rlb>(loop [n 0] (while (pos? n) (recur (dec n))))
<rlb>oops :) [n 10]
<leoprikler>hmm, a compiler from clojure to tree-il