IRC channel logs

2024-05-09.log

back to list of logs

<coyote>hey everyone :-) I'm looking at Hoot and the previous year's Lisp Game Jam submission and how they used WASM-4 as a target platform, and I was wondering if that'd be possible to do while writing Scheme instead of WAT?
<coyote>I thought something in `(hoot ffi)` would help but seems like that's for interacting with the JS-side of the library, right?
<graywolf>Are guile modules ever garbage collected?
<wakyct>coyote, I thought there was a Guile template already? https://itch.io/jam/spring-lisp-game-jam-2024/topic/3713915/guile-hoot-game-template-repository
<wakyct>or maybe I don't understand that
<coyote>there is one, that's using the JavaScript reflection stuff to interact with a canvas
<coyote>I was mostly looking to use WASM-4 (https://wasm4.org/), which uses "pure" WebAssembly
<dsmith>!uptime
<sneek>I've been serving for one month
<sneek>This system has been up 8 weeks, 1 day, 12 hours, 49 minutes
<dsmith>sneek, botsnack
<sneek>:)
<KE0VVT>cow_2001 &al.: Should I put a newline before a docstring?
<cow_2001>O_O
<cow_2001>oh, no
<cow_2001>it's "Blah blah\nblah blah", not "\nBlah blah\nblah blah"
<cow_2001>look up some other things with existing docstrings
<cow_2001>KE0VVT:
<cow_2001>let me see... what has some good docstrings?
<cow_2001>srfi-1's span
<cow_2001>i see that sqrt's docstring is generated from texinfo in ./libguile/numbers.c's line 7180
<cow_2001>KE0VVT:
<cow_2001>KE0VVT: C is not my first language :<
<KE0VVT>cow_2001: I see. Do put a newline before a docstring.
<cow_2001>nono
<cow_2001>what no
<cow_2001>KE0VVT: D:<
<KE0VVT>cow_2001: Yes.
<KE0VVT>cow_2001: https://0x0.st/X8ez.txt
<cow_2001>oh, that kind of newline
<cow_2001>sorry
<dokma>matijja: did you do any work on guile-websocket ??
<dthompson>coyote: wasm-4 is not a suitable host platform for scheme. you can still use the hoot toolchain to build binaries for it, though, you just won't be compiling scheme programs at that point.
<dthompson>ACTION got a nice little patch in his inbox for guile-websocket
<dthompson>love to get nice little patches
<tomnor>(define fmt "Hello ~a\n")
<tomnor>(format #f fmt "world")
<tomnor>;;; <stdin>:476:0: warning: non-literal format string
<tomnor>why is that a worry?
<chrislck> https://git.savannah.gnu.org/cgit/guile.git/tree/module/language/tree-il/analyze.scm#n1341 dunno why... but is the warning meant to be suppressed if the varname is 'fmt'?
<tomnor>Very confusing, that comment seem to imply there should be no warning in my example?
<tomnor>In case my variable fmt is a lexical variable
<chrislck>here comes the author of this commit
<tomnor>But main question is why a non-literal string is a worry
<mwette>I believe non-constant format strings are considered a security risk (in C at least). One can take over the stack, IIRC.
<mwette>but it's not a literal; someone can change fmt after compilation
<mwette>To do things like that you can use (define (my-fmt port fmt . args) (apply format port fmt args)) I believe.
<chrislck>(set! fmt "\"; DROP TABLES students;")
<mwette>^ what chrislck said
<dthompson>I wish guile did safe sexp-based string formatting rather than encoding stuff in strings
<mwette>dthompson: any specific reason? format strings are going to be compact (i.e., convenient) than sexps, IMO
<mwette>One solution (as I use in my printf impl) is to allow format strings, or sexps (from compiling format strings).
<dthompson>I'd rather have syntax that compiles to the relevant conversion + print calls and using sexps makes reading and editing much easier and expressive
<dthompson>yeah format strings are compact but once you need to do anything significant it's very annoying. printing floating numbers to so many decimal places... I certainly can't remember how to do it without looking it up each time
<old>wondering what it would take to have typed Guile like Racket has? https://docs.racket-lang.org/ts-guide/optimization.html
<ArneBab>old: AFAIK parts of that already happen if you guard part of your code with a type check like throwing an error in (magnitude x y) as dthompson shows it: https://dthompson.us/posts/optimizing-guile-scheme.html
<ArneBab>old: so you could write types and compile these simply into type assertions. You could even stay close close to regular scheme feels by following how sph-sc does it: (define (myfunction a b) (int char void) "a description of this function" (return 1)) https://github.com/sph-mn/sph-sc
<ArneBab>⇒ (define-typed (name arg) (return-type arg-type)
<ArneBab> ...)
<ArneBab>old: like this: (define-syntax-rule (define-typed (name args ...) (ret? types ...) body ...) (define (name args ...) (map (λ (type? argument) (unless (type? argument) (error "type error ~a ~a" type? argument))) (list types ...) (list args ...) ) (let ((res body ...)) (unless (ret? res) (error "type error: return value ~a does not match ~a" res ret?)) res)))
<ArneBab>(currently only works for one-line procedures)
<ArneBab>old: I just wrote a less limited version here: https://www.draketo.de/software/guile-snippets.html#define-typed