Yay objects work so much better now. Here's how I have objects implemented now.
So a function's return value is not type-checked, just like any parameters. I exploit this by making any objects just a function with a return value in slot 3. When you initialize an object, this is the code:
and this is the output:
I then push the name onto a stack of declared objects, and push a bit of info onto another stack that lets the compiler know to replace any instance of "test" with "test()."
During runtime, the function ASSIGN_ is called and the following output is made into slot 3:
COMMON DEF test()
RETURN somevalue 'this is a literal
Now objects should be mutable. This creates a small problem. Because of this method, assigning a new value to an object requires RUNTIME overwriting of the function (so now I have some real JIT compilation going on). If the precompiler encounters something along the lines of:
it is compiled into
I then have a function called ASSIGN__ that will find the function with the name "test," delete it, write a new function called "test" with a literal return value of "hi!" and execute slot 3. This redefines the function with the new return value, and all is good.
The good about this method:
*Objects behave just like they would in a language like C#. If you give an object the value 5, its type (found with the "typeof" function) becomes "int," but is still 100% mutable. Thus, changing its value afterwards to "u r a skrub" makes the "typeof" function return "string."
*Conversion between objects and other data types is eliminated (using "obj" to convert to an object was previously required).
The bad about this method:
*Changing the value of an object is slow.