Well for the few adventurous souls who have tried Tao, I have some major changes. Based on my experience writing a real-time system in Tao I’ve decided to change the way that variables are handled. Up until now it’s been no big deal because by in large Tao objects were either programmed at the beginning with everything they needed to know, or simply were called into existence for a few milliseconds, updated a database, and winked out of existence.
 
Then I had to be a smart ass and try to use Tao for a class I was teaching on gaming. The program was simple enough. You write the logic for fish that swim around a tank. The fish are objects. The tank is an object. They export data to a simulator physics and rendering engine. QED, right?
 
Nope.
 
I stumbled face first into a limitation in the way Tao implements it’s execution stack. I decided to try wrapping the method calls inside a [dict with] statement. The problem is, dict provides you temporary copies of variables, and the writes the copy back into the dict at the end of the loop. If you call a sub-function inside of a function, any changes to the dict get written into the dict. And THEN the caller function resolves, and the system reverts to the caller’s state.
 
My solution is along the “Fuck this” school of thought. The effort and expense in term of discovering what values have changed, or worse, deciding to write the same values back into the database after every function call, are not worth it to me. I’ve had so many problems making changes from inside of functions stick properly, it’s time I put my foot down and say “All we are doing is confusing ourselves.”
 
My answer is that if you want to change the value of an object’s variable you explicitly call “cset”. If you want the most up to date version of a variable after calling a sub-function, use “cget”. Beyond that, the local variables are a convenience. They are set to the present value at the start of a method call.
 
It occurred to me after this new radical design that it allows me to store object data directly in Sqlite now. And while I have found dicts to be a wonderful tool, methinks it’s time to stop lionizing them and get back to writing my twisted object system.
 
Next up I think will be running procs directly from the database. The namespace code was cool and all, but I have some evil ideas for how to be able to save state between runs, and allow objects to modify their own methods.
November 10, 2007
New Change: All variables in Tao are “Static”
Our Blog