IRC channel logs
2025-06-24.log
back to list of logs
<trannus_aran>Hey so I got a question about building objects out of lambdas <trannus_aran>I can make a procedure the returns a lambda that dispatches on a quoted symbol easily enough (ie methods are fine) <trannus_aran>but how would I handle updates to state that return a new instance of the object while preserving the old one in memory? <trannus_aran>I looked over the goblins source after mucking around on my own a bit but hit wall in figuring out exactly how a "bcom" equivalent would work in just R⁵/R⁷RS-isms <dpk>you’d need to call the constructor procedure with arguments that result in the updated object <dthompson>if you avoid set! and other mutators then you'll have both the old and new objects <trannus_aran>Right, and that's kinda where I'm at, so in order to not have to reassign what object the instance name points to...would all accessors need to implicitly pass some sort of "generation number" parameter? Car some list of object generations per-transaction that gets a new instance cons'd on whenever something stateful happens? <dpk>i don’t understand this concern <dpk>what do you mean by ‘reassign what object the instance name points to’ ? <dpk>(what do you mean by ‘instance name’ ?) <dthompson>maybe this will help: in goblins, an actor reference is basically a mutable pointer to an immutable object. when an actor changes its behavior (state), that mutable pointer is updated. <trannus_aran>like if you had a cat object that tracked how many times it was fed. some-cat 'feed would return a new cat where 'get-times-fed would be 1 instead of 0, right? But if you want to do anything with that new cat, you either need a new variable or a convoluted message call that includes all the stateful stuff that's happened <trannus_aran>dthompson: okay, so the reference is ultimately a mutable object! <trannus_aran>I'm trying to get a contrived example of this working in chibi so I can transfer it to hoot <dpk>you can send 'feed to the new cat, and you’ll get a third cat where 'get-times-fed would return 2 <trannus_aran>Exactly! But ultimately, as it stands rn, I don't have some global pointer to "the cat in question" that I can query and send messages to <trannus_aran>(with maybe some implicit 'latest flag for the generation) <dthompson>trannus_aran: right, you need some form of mutability if you want a single 'cat' that you can send messages to that always reaches its current state <dthompson>been printing out a lot of papers and doing a lot of highlighting this past week, heh