IRC channel logs

2024-02-16.log

back to list of logs

<old>I wonder regarding the new Guile GC
<old>if it is possible to have a borrow checker like Rust in a runtime that has a GC? Would it be possible to have a scheme without a GC but only a borrowing checker?
<dthompson>not sure it would be possible
<Arsen>don't see why not, with a lot of uglyfication
<dthompson>I don't know how you'd map scheme's semantics onto a borrow checker
<lilyp>I'm fairly certain you could do a refcounted Scheme if you forego more advanced stuff like continuations etc.
<dthompson>I guess if we were to "get serious" about this we should define what "scheme" is.
<dthompson>a question: could r7rs-small be faithfully implemented using a borrow checker instead of traditional gc?
<dthompson>my spicy take is that borrow checking is rebranded gc for people who have decided that gc is bad
<Arsen>quite wrong too :)
<dthompson>the rust folks seem to twist themselves in knots trying to avoid gc when sometimes maybe the right answer would be to use gc
<Arsen>correct, but doesn't make the above correct too ;)
<dthompson>?
<dthompson>I said it was a spicy take, not nuanced, etc. etc.
<Arsen>they do do that, but there's far more to putting resource lifetimes into static analysis than just memory management
<Arsen>GC languages tend to be bad at that (obviously, not due to the GC, but due to overreloance on it)
<lilyp>In my humble opinion, the borrow checker is C++ lifetime management for folks who don't understand C++.
<dthompson>yes sure, again it was an intentionally reductionist take. kind of a joke and kind of not
<dthompson>the rust rewrite of guile is going well, I hear
<lilyp>r7rs-small has call/cc and that's not fun without a GC
<dthompson>call/cc just isn't fun in general ;)
<lilyp>Well, fair, but MM-wise it's the only thing that you can not easily manage statically/with refcounts.
<dthompson>well someone should feel free to write borrow checked scheme then :)
<lilyp>(unless I'm gravely mistaken about lambda)
<lilyp>Welp, turns out we're late to the party anyways https://github.com/volution/vonuvoli-scheme
<dthompson>heh, figures
<dthompson>good find
<lilyp>"with focus on [...] deployability" (don't spoil the joke)
<dthompson>lol
<dthompson>just yesterday I was considering if I should try building deno instead of using node but then I saw the rust dependency and nope'd out
<lilyp>And look at that, they too realized that call/cc doesn't fit into Rust all that well :)
<dthompson>heh this list is not surprising
<dthompson>both from a "this is hard in rust" and "these are lesser used features" point of view
<dthompson>not having bignums is a pretty big hole though
<lilyp> https://github.com/kenpratt/rusty_scheme has continuations, funnily
<dthompson>I feel like I've seen at least one other scheme written in rust...
<lilyp>well, those are two of the top three results from a quick search
<dthompson>maybe it was a custom lisp rather than a scheme
<jackhill>dthompson: I think I've seen another one too, but can't find it right off. Funnily enough I remember it being targeted as an extension language :) https://github.com/alilleybrinker/langs-in-rust is an interesting list though
<jackhill>lilyp: as someone who doesn't yet appreciate all of C++ some of what rust is selling sounds attractive :รพ
<jackhill>ah, yes, https://github.com/mattwparas/steel is the one I remember running into
<dthompson>ah I think that's it!
<old>borrowing checker also has the property of guaranting data race free I think
<old>someting a GC can not do
<old>But I guess this can all be done with good abstraction around mutex and atomic operations
<old>but the Rust evangilist will say that your code can not compile if there's possible race condition
<old>although I doubt that
<Arsen>well, that's technically true.. but the way it achieves that is very restrictive
<graywolf>Hello. If I would like to generate a guile sexp, what exactly do I need to escape/convert in a strings? I realize I need to convert " to \" and \ to \\. Anything else?
<gonzigdude>your are generating the sexp from what?
<graywolf>I have a array of strings and want to generate a ("foo" "bar" ...) from it
<graywolf>So I want to know how do I need to escape the the strings
<graywolf>I *could* just use json, but would like to avoid introducing the dependency on json lib on the guile side
<lilyp>if you have access to C you could call scm_from_utf8_string
<graywolf>Sadly the program is in golang :/
<lloda>if you use guile-raw-strings you don't need escaping
<rlb>graywolf: from a quick check, looks like it might depend on the standard, i.e. r5rs looks like you could get away with that, but r7rs supports more escaping. See top right of page 62: https://standards.scheme.org/official/r7rs.pdf
<rlb>But I'd also have to double-check our docs/reader to see what we actually do right now.
<apteryx>does guile do some dependency tracking itself to map .go to .scm files?
<apteryx>it seems yes, as when I switch from .scm to .sld I must specify dependency relationships manually in the build system
<dthompson>what the heck does ".sld" mean?
<apteryx>scheme library definition, I reckon, from R7RS
<dthompson>oh interesting, I have the r7rs-small pdf open regularly and missed that
<dthompson>thanks
<apteryx>np!
<old>hey which is faster
<old>1. (append x '())
<old>2. (append '() x)
<dthompson>2 because it would just return x
<old>okay good to know
<dthompson>but this all depends on the implementation
<old>okay
<dthompson>if it's a straightforward implementation, then in case 1 a new list is cons'd up for every element in x
<old>I often find myself defining a list with default thing in it and optionally more stuff if some condition is met. Thus I often do: (append (if true x '()) rest)
<dthompson>the performance details don't really matter unless you have big lists, but putting the smaller list first (if order doesn't matter) will be faster
<old>that or something along: (filter (negate unspecified?) `(1 2 3 ,(when #f #t))) for example
<old>true
<dthompson>(append '(a) '(b c d e f)) is just (cons 'a '(b c d e f))
<old>Just wondering if there's a better way to do that kind of list
<dthompson>I guess I'd write it slightly different: (if add-stuff? (append '(blah) stuff) stuff)
<dthompson>not really for performance but just because I like that structure more
<old>the thing is
<old>you might have multiple condition
<old>that add multiple different element
<old>thus the when and unspecified? just scale better imo
<old>in term of adding more thing
<ieure>Clojure's cond-> is really nice for stuff like that: (cond-> '(b c d e f) add-stuff? (append '(foo)) add-other-stuff? (append '(bar baz)))
<dthompson>yeah you could either thread it with a macro or use quasiquote or something
<dthompson>multiple ways to do it, best depends on specific situation
<old>hmm I see
<old>that's cleaner
<old>oh well that was easy
<old> https://paste.sr.ht/~old/abc5b848c24c4f7f7cea4a559a6ef52a3f5516fc
<ieure>old, That only works for one branch though, right? Clojure's cond-> branches fall through, so if (in my example) add-stuff? and add-other-stuff? are truthy, you get the equivalent of: (append (append '(foo) '(b c d e f)) '(bar baz))
<apteryx>re my question regarding .sld extension not being auto-compiled during the build (thus requiring manual dependency resolution in build system), it can be avoided by adding --r7rs to 'guild compile'
<dthompson>without having to invent new language, you could just quasiquote it: `(,@(if foo? '(foo) '()) ,@(if bar? '(bar) '()) . ,baz)
<ieure>Okay, wait, actually: (append (append '(b c d e f) '(foo)) '(bar baz))
<apteryx>this calls install-r7rs! which adds the .sld extension to the %load-extensions variable
<old>ieure: hmm I think it works fine?
<old>yup
<ieure>Ah, okay.
<ieure>I am not super up on Scheme macros.
<old>dthompson: right that works too
<old>I don't mind having a syntax tho
<dthompson>yeah do what sparks joy :)
<apteryx>daviid: would you mind if I merge my changes for guile-lib and issue a new release? these ones: <https://lists.gnu.org/archive/html/guile-devel/2024-02/msg00021.html>; only the logging library is touched.
<rlb>old: if it's useful (and not incorrect), here's a clj cond-> for guile: https://codeberg.org/lokke/lokke/src/branch/main/mod/lokke/base/syntax.scm#L682-L688
<rlb>...Of course you'll need to import (if . %scm-if), or similar -- see the define-module for that.
<rlb>Bunch of other scm oriented clj stuff in there, fwiw.
<old>rlb: nice thank you
<daviid>apteryx: please wait, i'd to make a suggestion related to the interface change you propose and some other 'minor' (commit style) comment(s) - if not later today, at most till the end of this we, tx
<daviid>meanwhile, would you like to point to some code where you use the added source properties arg and, if possible, paste an example of how it's effectively logged, tx
<daviid>have to go afk, bbl
<apteryx>daviid: ack, thanks for the response. will send a link to an example
<apteryx>daviid: here's an example which makes use of the source properties: https://issues.guix.gnu.org/68946#1