Progress Report #7

Back at it again, this time I’ve made some important bug fixes that have laid hidden since branch Cheetah. Uh oh. Sometimes a bug can be simply reference counting too much, in which case, we call it a memory leak. The major issue, however, was a parsing bug that duplicated variable address names. Hard to believe I missed something as important as that, but it required a certain state of the parser, so I don’t feel quite as bad about missing it. In any case, those are done.

In other news, lists now have lots of functionality, and they are debugged so they work properly. Lists in general have a peculiar functionality in Copper as opposed to other languages. In keeping with the proper ownership model in Copper, any function assigned to a list first is “owned” by that list, much like any function assigned to a variable first is owned by that variable. This prevents pointer loops that would otherwise result in memory leaks. However, it does make for a peculiar scenario when you attempt to assign to it. Rather than copy the function, it saves a pointer to it. What happens when the function is dropped by its original owner? The list ends up with an empty function. For the list to be the true owner, the function needs to be created inside of the list constructor function.

I’ll admit that, in some cases, it might be nice to have the list contain true copies. However, I’d rather create a built-in “copy” function than change this default action.

Aside from that, I’ve managed to find some areas that can be tweaked for optimization. Both involve perhaps excessive use of copy constructors. One area is tricky since it entails copying scopes and hasn’t shown amazing promise in benchmark trials of partial implementations of the changes. All that to say it’s a “maybe”. The other area of optimization involves the direct assignment of created objects to their variables. I had assumed this was being done already, but apparently, I was copying data so as to make sure it wasn’t already linked to something else. To put it in more practical terms, without the copy, a=5, b=a would cause “b” and “a” to be linked, which they should not be. However, a=5 would replicate the data just to save it in “a”. This would horribly slow down the assignment of large, newly-created large lists. The optimization fixes this by bypassing the copy if nothing else points to the data.

To-Dos

Strings need a sub-string accessor function (which I’ll call something like “substr”) and an equality function (which I’ll probably call “match” for lack of a better name since “equal” is taken and “equals” is too easy to mistake).

Some changes may occur with the logging system so that it’s more flexible and can be set up to support different locales without needing to create a new string every time a new error message is added internally. I was using error codes, but using only a single code for an error means that you have to make a new type for every error. I’d rather have a few error types.

Finally, documentation needs to be updated.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s