After deliberating over the matter, I’ve decided that it’d be best to write an extension for Copper that would enable file reading and writing. This would enable the language to finally be general purpose, putting it among the big boys like Python. While the current Copper VM is certainly not fast enough to compete, the ease, power, and syntax of the language make it a highly tempting alternative.
A very simple byte extension was added to Copper’s extension collection recently. It’s just a convenience class with a few features including byte flipping, bit flipping, bit setting and getting. The ByteObject class extends NumericObject, so math operations are possible. Creating a byte instance is done using strings rather than numbers or hex because the Copper VM does not support hex numbers.
mybyte = byte("00001101")
The full byte does not need to be given. Any number of bits less than 8 can be given, and these will set the lowest bits of the byte. The above code could have been written:
mybyte = byte("1101")
Functions are documented at the top of file cu_bytebasics.h.
While attempting to program the image of a mandelbrot, I unwittingly chose the easy, convenient, yet very slow way of writing my complex number class. Let’s have a look.
Someone noted that my last post sounded like I would not fix bugs. I will go back and fix bugs in the virtual machine and extension code if_ someone finds them, but I am quite confident there are none. I know that sounds overconfident, but I have done plenty of testing to weed out the problems. Because Copper is a simple language, there are not many ways to trip up the virtual machine. Ironically, it does mean odd code is acceptable. You could even feed this_ entire blog post into the VM and it would all be legal code. Go ahead and try it.