My post was a long way of saying "I love it, please implement it."
That's a funny and unexpected twist that reminds me to stop ignoring the exact same book that I only went half-through by now... ![]()
I have pretty much given up on instilling this attitude in other people, but I am still following it myself, so no such convenience for me — I still write my tests before implementation, that is when I am writing any tests. ![]()
In fact I am using SDL, and I am doing a kind of React-inspired UI toolkit myself. Mind, this is all still in Python, so I am trying to achieve separation of state and behavior by applying discipline pretty much. In Clojure with its Persistent (meaning Immutable) data structures that would be the default.
I think I'd define functions to handle each of the five dialogs. That way, if I were developing the dialog that's normally called nested five deep: I could make my changes in the source file buffer,
racket-run, and in the resulting REPL, I could call that function for the 5th dialog. Skip right to it.
That's also a possible way to do it I guess, but I haven't tried that. I think setting up all the required inputs is not that much in the way even. It may just look odd hanging on the empty screen as opposed to how it will work when you actually run the game. Need to give it a try and see — thanks for the suggestion!
Now that I mentioned Clojure once again: is there facility in Racket that has the same effect as defonce? That potentially would immediately solve the problem for me, as I would be able to re-evaluate all the code, while preserving whatever state I have accrued so far by interacting with the game.
Structs and prefab — I am aware of already, but haven't read the manual up to classes yet. I do not know if I will be using them yet, though. ![]()
I looked up defonce and see there are two aspects to it:
- evaluating once
- thread local values
In Racket those concerns are usually split.
To cache the result of an expensive computation we often use memoization.
It's common to roll your own, but there are some libraries [1], [2] to use.
To shadow "the root value" with a thread local value, use parameters.
Just be aware, that referencing a parameter is slower than referencing a normal variable.
--
Apropos Clojure - don't forget Racket now has immutable tree lists.