IRC channel logs
2024-03-07.log
back to list of logs
<dthompson>civodul: the reason for needing a record is that we need something to encapsulate the bytevector and offset. whether or not to build a type hierarchy for strong typing could be up for debate. personally I see value in it and it's what ftypes do <dthompson>civodul: but hey I'm glad you were able to try it so quickly and that you like it! can't think of a much better endorsement :) <dthompson>you can also directly get/set into bytevectors without an intermediate record btw! bytestruct-pack and bytestruct-unpack do that <dthompson>yeah, it's a must-have for me for packing gpu buffers with vertex data <dthompson>but the wrapper structs are nice when you want encapsulation <dthompson>and to give someone an API that looks like a regular Scheme record <dthompson>(bytestruct-unpack <vec2> ((y)) (f32vector 1.0 2.0) 0) would return 2.0 <freakingpenguin>I have to define a public function with some shared logic in several different modules due to some other code and figured macros were the least code-dupe way to handle it. <freakingpenguin>I should be able to cludge something together with functions but a (define-foo) macro feels like it would be cleaner. <rlb>freakingpenguin: yes, I think more or less -- try (macroexpand '(test 'foo)) <rlb>But you can likely use syntax case, and break hygiene if you like, or you could (less safely, depending on the rest) use define-macro. <rlb>And here with a syntax-case variant of your macro: <rlb>scheme@(guile-user)> (macroexpand '(test 'foo)) <rlb>$1 = #<tree-il (define bar-46dea41ac6af4d9 (const foo))> <freakingpenguin>rlb: Thanks a bunch! From what I've read of syntax-case in the manual it looks like datum->syntax is how I'd intentionally break hygiene, is that right? <rlb>freakingpenguin: yep <rlb>ACTION double-checks that name wasn't introduced some other way, now that he said that... <rlb>Also, if your end-goal is a module, I'd probably work immediately with that, so you have the semantics (top-level and otherwise) you want from the start. <rlb>Those define-generics just below the link are also "top level" defs, fwiw. <freakingpenguin>Thanks for the example! Is... that project an implementation of Clojure in Guile? <rlb>fsvo implementation -- it's intended to be heading in that direction :) <freakingpenguin>"For a more Scheme oriented experience in Scheme" I love this community. Everywhere I look there's some cool new project. <rlb>Yeah, up to a point I've tried to keep some bits that might also be useful to guile implemented first as mostly scheme-friendly, and then I've build the clj side on top. <mwette>Due to the day job, I missed the entire struct conversation. bytestructures provides macros to generate offsets of struct-in-struct-...-in-structs. <mwette>I have been using that in ffi-helper, but a little while ago I started looking at new form. My original interest was in supporting cross architecture access. (e.g., accessing data structures snarfed from microcontrollers). <mwette>Also, I plan to parse C structures down to primitive types: u8, i16, f32, etc. so that equality predicates are doable. <flatwhatson>bytestructs sound great, just need something like nyacc to autogen them from C headers <old>mwette: I've had some syntax that does that <old>defining complex C-struct around a bytevector <old>by complex I mean compound one, not just flat structure. With union and enum <old>it is just very slow unfortunatelly <old>I'm not sure if that's what you are refering to by bytestructures, I have not seen the conversation <mwette>OK. nyacc will generate bytestructure descriptors for all structs inside include files. The bytestructures package provides accessors, but no in the flavor of scheme records. <old>hm it looks similar to what I have <old>these are the bindings for libev I made, manually written <old>but it is nice to see we can have something portable across Scheme with bytestructures <mwette>nyacc autogenerates the scheme code. For glib gobject.h the file is ~13,000 lines of code; for gtk2.h it's 98k lines of code. <mwette>mixing C and Scheme has its idiosyncrasies <jmes>How do I make (file-exists? "$XDG_RUNTIME_DIR/frumble") understand the environment variable? <jmes>Generally, how do "expand" strings with environment vars? <mwette>(file-exists? (string-append (getenv "XDG_RUNTIME_DIR") "/frumble")) <jmes>mwette: Thanks a bunch. And the universe seems to be poking fun at me because as soon as I bother you about it I finally find the relevant docs online... <ArneBab>Does anyone have a high performance implementation of skip lists for Guile? <sneek>I've been serving for 10 days <sneek>This system has been up 48 weeks, 4 days, 21 hours, 14 minutes <freakingpenguin>Pretty sure the problem is from wrapping the list in a syntax but I can't get rid of it. <freakingpenguin>In this case I guess I could turn it into a datum but in my actual use case that list would contain variables, not constants, so I don't think that would work. <mwette>maybe expand to (define foo (if (every ...) bar (error ""))) <old>freakingpenguin: fender is not what you want if the elements are not constant I think <freakingpenguin>Alrighty, thanks! Do you know of any good resources on this topic? The manual is a bit hard to parse sometimes. <old>freakingpenguin: right because the expander can deduce that hello is a constant number <old>try it inside a function that received some parameter <old>anyway, I would not mix eval and fence, you might encouter issue in the future <freakingpenguin>You're right, it can't handle that. Putting in a conditional error clause is definitely cleaner, just wish I could understand all the finer points of macros. Guess that just comes with practice. <dsmith>freakingpenguin, ^^ Though that's only syntax-rules, not syntax-case