IRC channel logs

2025-11-05.log

back to list of logs

<kestrelwx>Is there no good RNG I can get in browser?
<cwebber>heya kestrelwx, you might want https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveBits
<dthompson>kestrelwx: I'm guessing you already know about Math.random?
<dthompson>unfortunately Math.random cannot be seeded.
<cwebber>oh, yeah what I recommended was more for cryptography purposes
<cwebber>if you want it for games, Math.random is better
<cwebber>also TZAG!
<dthompson>yeah I think kestrelwx just needs something for the game jam
<dthompson>tzag!
<cwebber>ok yeah different RNG use case ;)
<kestrelwx>I think I'll see to port the `srfi-27` reference.
<kestrelwx>Hello! And thanks.
<dthompson>kestrelwx: oh right! srfi-27! guile has that but I haven't used it. give it a shot
<dthompson>ah there's just one missing thing: gettimeofday. replace that and I think it should work.
<kestrelwx>Would `(ice-9 random)` compile?
<dthompson>I don't see any scheme module with that name in guile
<dthompson>so if that's a valid module then it's implemented in c
<kestrelwx>Sorry, I think it's not a module at all, but Guile's SRFI-27 seems to be implemented in terms of Guile's own RNG implementation.
<dthompson>yeah, seems so.
<dthompson>I missed that when I took a quick look
<dthompson>implementing that in hoot is on the todo list but something we haven't gotten around to
<kestrelwx>Okay, I didn't ensure it's all proper, but seems to work alright. I'll clean up, try the tests it has and push the commits in a bit. I think the implementation I took is slow, but for this once that's not a problem.
<kestrelwx>I chose the scheme48 implementation here. https://github.com/scheme-requests-for-implementation/srfi-27
<kestrelwx>I think I could also make it take Math.random() instead of Date.now() too.
<dthompson>kestrelwx: cool, thanks for the update!
<kestrelwx>dthompson: Oh, I wanted to ask, some WebGL procedures have return type of `any`, if they might return different results. Right now, I have `any` mapped to `(ref extern)`, so they are opaque to Scheme. Do I need to write a number of JS wrappers for each possible return type? Or is there a better way?
<kestrelwx>For example `getShaderParameter` can be one of the integer number types, or it can be a string, depending on `GLenum` value passed to it by the application. Some other functions might return a typed array as well, though.
<kestrelwx>I guess I could have a JS function that inspects the value and best-effort returns an `scm` value. It's also fine to go through these case by case, but I am curious in terms of binding generation.
<dthompson>kestrelwx: you'll want a foreign procedure for each possible return type
<dthompson>otherwise you'll have to handle things like turning ints into fixnums
<kestrelwx>Oh, can I not get #to_scm?
<dthompson>I think that's a private method
<dthompson>I'd need to re-read some code to see if there's a way to do this
<dthompson>if there is then the return type should be (ref eq), not (ref extern)
<kestrelwx>I guess I should just see if a `TypedArray` being passed to `api.scm_from_extern` raises an exceptions. `call_extern` does this conversion already, so I might already do `(ref eq)` for these.
<dthompson>unsure if that's the best way. what's wrong with one function per type signature? that's what the original opengl api does, after all.
<kestrelwx>I just can't know the possible types from an IDL spec, otherwise it's fine.
<dthompson>ah okay
<dthompson>yeah that's an issue...
<kestrelwx>Oh, I can not get `call_extern`.
<kestrelwx>Until tomorrow!