I love the smell of code in the morning



I need to make a couple of notes before I forget.

I went through and put in code to set b to 1 or -1 on the methods that needed it. I was going to have write and paste, both inner and outer return a -1 if they were called while the buffer was empty. However, I changed my mind. Instead, the outer commands return -1 when a figure tries to write or paste to itself with the outer head. The same thing will happen with read and cut. As it happens, that means that inner write and inner paste never set b to -1. I went ahead and had them set b to 1, just for the sake of consistency.

Meanwhile, in move inner, b is set to -1 if the method tries to move the inner head further than it can go, and otherwise sets b to 1. That gives a figure a way to tell when it has reached the top or bottom of the figure. Read commands also set b to -1 if a read command is sent while the head is at the end of the figure, one spot further than there are numbers to be read.

I need to make sure that any outer commands, like read cut write or paste, set the otherHead field of the figure being read from or written to, to be the address of the figure that is doing the reading or writing.

I’ve still got several outer head commands to implement, and I’m way behind on comments. I actually think I’ll go ahead and finish implementing the remaining ports before I catch up on the docs. It shouldn’t, judging by the methods I’ve already created, take too long. With a combination of cut and paste, and find and replace, I can adapt the methods I’ve already implemented to do what they do, only to another figure, instead of the one that is calling the outer head ports.

I have no clue how long catching up on the documentation will take, but I don’t want to go further without getting that done. There’s just too many little details that could get lost if I don’t take care of it soon.

Meanwhile, last night, I tested setting one of the slots in the realm’s population array to null. It worked. I ran it a couple of times, but stopped when I realized that I was making orphans. The one figure would write out a child copy of itself, add a slight mutation, and then the parent figure got deleted. The system is very far from creating anything that would count as living, but it still made me feel just enough guilt to make me stop screwing around and move on.

Okay, that’s where I am, and where I’m going.

I got the addresses handled in what’s there so far. I made sure the outerWrite command set the target figures’ otherAddress field to be the address of the source figure.

While I was at it, I changed some of the test code messages, so directions up and down are reversed from before. I just picture 0 at the top of the array, so adding is going down to me.

When a method needs to see if the outer Head is pointing at the source figure, it should test the addresses. It was using the name field, but I might switch that to a string or some other object. I changed that too. That’s why I did all this in the morning; I had too much that I might forget to do if I didn’t get it done.

If x==address

Got an episode to get done.


Leave a Reply