12.21.2011

four-state logic

As describe in my previous post, I' tinkered around with stuff, dropped all that persistent history of true/false values and introduced a foru-state logic system I came along while designing my own macros for this. Not to my surprise, there's a formal description of a four-state logic by someone who's name I forgot but I guess it's a bit different from mine, though in principal the same. And what does this have to do with getting better function feedack? Well, I have the states true, false, maybe and unknow where maybe is th result of true and false. Maybe will always stay maybe, whatever or, and or not operation is involved. Thus, maybe is the dominant state in this system. The submissive state is unknown because everytime you put something know into an unknow system, you'll eventually know something about it. Unknown is the 0 in number system, maybe is infinity. I've combined with a condition macro that will accumulate all previous conditions and end if it's not true anymore. So the function return value will tell me whether atleast one thing, everything or nothing succeeded. It works for boolean/ternary expressions and therefore function calls and variables, making it less redundant when writing parameter checks and so on.

I'm pleased with this. Only problem is that I'd have to rewrite all parameter checks then. Well, atleast I don't have to alter the logic. I've also deleted a bunch of codes not useful, effective or simply uncontinuable. I will focus on my ressource shit for now and hope it to be done soon. Guess I've now sorted some more stuff out that annoyed me all the time. I usually don't do such "language extensions" as I'd call it in non-personal projects. It takes too much time if you don't already now everything you want and it don't add any real productivity. However, it makes things nicer and easier to work with. I don't think that I would be able to easily do this in other languages. I love macros. But I don't misuse or fear them as others often do. Oh and did I mention how elegant my solution of defining a constant, global logic state table is? In worst case, a single four-state operation would 12 checks. That's too long to execute and too code-heavy for inline use. Using a global array is simply optimal in this case! Such small optimized solution always warm my programmer's heart...

And if I'm done with the ressource stuff (will make it very, very simply this time), I'll do something different, like doing the backtrack system I always wanted to make. Very simple of course with a bunch of callback functions. I don't intend to use it for time-critical tasks, so I really don't care about making bulky macro systems anymore... I mean really, I could've started like this in the beginning. But I'm loosing the focus so often that I'll probably have to through this all the time.

Whatever. Eier aus Stahl!

No comments: