IRC channel logs

2022-07-28.log

back to list of logs

<lilyp>dsmith-work: yeah, but *unspecified* kinda fits the purpose of None in python
<lilyp>like, you should never use call methods on None and it prints nothing, but you can still assign and compare None
<apteryx>None is a perfectly valid value to use for arguments in Python
<apteryx>hm, I tried adding a test, which fails, despite the output looking like it should be equal: https://paste.debian.net/1248587/
<apteryx>nevermind, I should have used test-equal
<flatwhatson>sometimes in python i make a private unspecified type to differentiate from callers passing None explicitly
<flatwhatson>in this sense None is probably closer to '()
<drakonis> https://github.com/8c6794b6/guile-tjit
<daviid>dthompson: hello! do you have, somewhere in one of your projects, an example of slot-definition alteration(s), at intialize time, using the mop (with or without a metaclass), that we could point to, for unexperienced goops users ... there are such examples in guile-gnome/g-golf, but there are a bit too complex as an intro to how to use the mop to (just) alter a slot-definition ...
<drakonis> https://github.com/NalaGinrut/guile-tjit this is a better fork
<dsmith-work>sneek: botsnack
<sneek>:)
<dsmith-work>!uptime
<sneek>I've been running for one month and 12 days
<sneek>This system has been up 6 weeks, 19 hours, 7 minutes
<dthompson>daviid: hmmm let me think...
<dthompson>daviid: this might be a little hard to read without some context but maybe this is what you are looking for https://git.dthompson.us/starling.git/tree/starling/node.scm#n69
<dthompson>I have a metaclass named <meta-node> that allows for 2 types of slot definition customizations: watch slots and asset slots.
<dthompson>watch slots are configured by adding '#:watch? #t' to a slot definition, in which case the slot setter procedure is wrapped in one that calls an on-change method. this allows for code that is alerted to changes in slot values.
<dthompson>asset slots are very specialized for this library, which is a video game engine. I have a class named <asset> which represents anything loaded from disk (images, audio, etc.) and adding '#:asset? #t' to a slot definition wraps the slot getter procedure in one that extracts the actual image, audio, etc. data out of the <asset> object so that it appears as though that data is available directly.
<dthompson>assets are a layer of indirection between the code that uses them and the underlying data on the file system. it allows for things like live asset reload when in development. if I edited an image the change would be immediately propagated into the running game.
<dthompson>okay I think that's enough context. :)
<dthompson>I have dreams of making an in-engine editor interface and for that I would add more slot options to mark slots that can be modified in this editor and their data type so the editor can present the proper widget (text box, slider, etc.)
<dthompson>daviid: oops I misremembered about the asset slot modifiers. ignore what I said about them. the watch slot code is very general purpose and could be easily extracted and explained outside of this context.
<dthompson>the asset stuff gets too complicated even for me, apparently!
<lilyp>is this about starling?
<dthompson>lilyp: yeah, sort of. daviid was looking for examples of a certain type of meta-object fanciness, and I showed him an example in the starling repo but I hadn't looked at the code in a long and got some stuff wrong.
<dthompson>in a long time*
<lilyp>ahh, I just saw slot watches and already knew that you defined them there
<dthompson>ha didn't know anyone else ever looked at this stuff
<dthompson>maybe one day it will turn into a real library but for now it's basically scribbles on a notepad
<lilyp>Well, I saw it thanks to the last LGJ
<dthompson>haven't looked at this code in like a year... I see so much I could improve on. maybe I'll play around with it soon.
<dthompson>ah right
<dthompson>that proved that it was at least a somewhat workable design
<lilyp>btw. some patches for guile-sdl2: https://gitlab.com/lilyp/guile-sdl2/-/commit/3f308fbf5359356953abcd3df5bac253fa626897.patch https://gitlab.com/lilyp/guile-sdl2/-/commit/485b01106d272952cde3c5cd737c116c744a98c5.patch
<dthompson>I was able to make that game pretty fast because of this stuff
<dthompson>lilyp: ooh thanks! the missing export is an easy one to add in. need to remind myself how the library loading stuff works before committing the second one because it's tricky business.
<dthompson>lilyp: what did you run into that this fixed?
<dthompson>did you have LD_LIBRARY_PATH set but that path didn't contain sdl2?
<lilyp>More or less, you encounter that bug if you run local builds backed by Guix packages.
<lilyp>your local build prepends LD_LIBRARY_PATH, but for guile-sdl2 I want to use the already baked one
<dthompson>lilyp: my local build of my lisp game jam entry?
<dthompson>I think your patch is good. it will still prioritize LD_LIBRARY_PATH but will fallback to the absolute file names that pkgconfig provided.
<lilyp>no, "your local build" in a project that uses guile-sdl2 but also defines its own shared libs to load
<lilyp>particularly, in Tsukundere I have a small wrapper around pango so that fonts aren't uggo
<dthompson>ah okay. so tsukundere has shared libs that get put on LD_LIBRARY_PATH.
<dthompson>I've thought about wrapping pango but ugh more C wrappers... I've had enough lol
<lilyp>It's only really a small part of pango, nothing worth using in a higher capacity.
<dthompson>I might have to do the same one day.
<lilyp>I'm also debating whether or not to switch to (guile-)cairo for rendering and only use the sdl portion for events
<dthompson>does cairo use the gpu? when I looked into it years ago it was only cpu rendering.
<dthompson>but perhaps things have changed
<ekaitz>dthompson: wikipedia says it uses hw acceleration when possible
<dthompson>it seems to be rather limited in what it can do.
<lilyp>my biggest concern with cairo is actually the hw rendering
<dthompson>but for lilyp the benefits of cairo's canvas drawing abilities may outweight the negatives
<dthompson>chickadee has a GPU based vector graphics rendering system, but obviously it's a far cry from more established technologies
<dthompson>lilyp: pushed both patches to master
<lilyp>thanks
<dthompson>thank you!
<dthompson>might be a time for a patch version bump and a release soon
<lilyp>there's no real api breakage, right?
<lilyp>btw. for your cursor bindings you forgot call-with-cursor :)
<dthompson>heh I was keeping it minimal :)
<dthompson>call-with-cursor has a nice flow to it
<ekaitz>lilyp: I should've add that too! but I don't really use that kind of functions that much
<dthompson>feel free to write it for your own stuff. I find that it's best if I keep the scope of guile-sdl2 to just wrappers and very few extras
<dthompson>call-with-cursor is actually slightly tricky because most SDL2 programs use an event loop
<dthompson>I mean it would be easy to implement but on the screen the cursor would change and then immediately revert unless the calling code was within some construct that plays nicely with an event loop
<dthompson>like a coroutine
<dthompson>if you did (call-with-cursor foo (lambda () (sleep 5))) or something you'd just stop the whole dang program for awhile
<daviid>dthompson: ok, thanks! sorry i asked and had togo afk ... so, are you ok if i point to this as an example, on the guile-user ML? if i find some time i may try to cook something a bit easier, then point to this as a concrete example, or maybe just point to this example, i'll see...
<dthompson>daviid: I don't mind at all, though I think creating a standalone example would be less overwhelming. modifying slots to watch for changes is a good example.
<daviid>ok great, tx
<dthompson>metaclasses, next-method, specializing MOP methods, etc. it's got it all
<daviid>:) - you're a goops wizard! it's good some of us are ... it shouldn't, but became a rare knowledge ...
<dthompson>it took me awhile to figure out. I think the Guile docs could be expanded to cover the MOP more thoroughly
<daviid>andnow newusersthink theyhave to use a macro to wrapdefine-class to change a slot definiti0n :(:(:(
<dthompson>that's what I thought I might have to do at first but it seemed so wrong that I kept looking for a way around it.
<dthompson>I knew there had to be a way and eventually I found it.
<daviid>yeah, i know it takes a while - but worth the invetment i would say ...
<dthompson>yeah this little game engine is my first time using goops in a serious way
<dthompson>I think it's working out pretty well. it's extremely flexible.
<daviid>and the code, your code, is extremely clean as well
<dthompson>thanks!
<ekaitz>dthompson: is it ready to make simple games? did you code any?
<dthompson>ekaitz: I made this game with it https://davexunit.itch.io/bonnie-bee
<ekaitz>good looking
<dthompson>ekaitz: engines are tricky things and this code is very experimental so I've made it publicly available in case someone finds any of it useful but it's not an officially released and supported thing
<dthompson>though it's built on Chickadee, which is an officially released and supported thing
<ekaitz>is the code of the game published too?
<dthompson>yup!
<ekaitz>oh yeah i just saw the link
<dthompson> https://git.dthompson.us/autumn-lisp-game-jam-2021.git
<dthompson>yeah
<ekaitz>btw the git clone line is broken in the itch.io page
<dthompson>I just saw that. it didn't use to be like that. I think itch.io may have introduced some sort of regression.
<dthompson>fixed it
<ekaitz>:)
<ekaitz>dthompson: it doesn't build directly hehe some guix hash mismatch thing is going on... I'll fix that tomorrow
<dthompson>ekaitz: not surprised that it is bitrotten at this point. sorry!
<dthompson>maybe I can update whatever is broken sometime
<ekaitz>don't worry, i'll fix it myself
<dthompson>good luck
<dthompson>hope it's easy