Other than saving few bytes of memory, why would one use ::static for methods of Object?
I found that if I use ::static, then I have to add prefix _self:- each time an object data member is referenced anywhere, making the code very hard to read.
Imagine having to write _self:-x + 3* _self:-x^2 + 2* _self:-y^3 and so on all the time, instead of just x+3*x^2+2*y^3. (where it is assumed here that x,y happened to be object private data members and not local variables for a proc inside the module).
But then I found if I remove ::static now _self:- no longer needed and can still get the benefit of using the object and the code works as before, but the code is now much more readable.
I know that by not using static, then a copy of each method is made for each new object.
I am OK with that. As I do not use that many objects any way (few at a time before GC cleans the ones I used).
But the benefit of much more readable code far outweights the little extra memory needed, and memory is cheap these days anyway. I got lots of RAM. An extra few MB's is not a big deal.
What Am I missing here? Why does all the Maple help and documenation say that one should use static for object methods then? But do not mention that by not using static:: then the code will become more readable since _self:- is not needed to be appeneded to each variable or method name.
Here is an example below to compare.
First example uses ::static methods, and the second does not.
One can see the difference The code is more clear in the second. Is there something else I am overlooking by not using ::static . I am still learning OOP in Maple, and could be overlooking something else. I definitly do not want to code using _self:-variable_name all the time if I have to use OOP in Maple as it makes the code hard to read.
Notice that in both examples, and for the exported methods, I used _self as first argument. This is OK. This is meant to allow client of the object to call it using object:-method() syntax which is what I prefer instead of method(object,....). syntax.
I am talking about the execssive use of _self internal to the module/object code when having to use ::static. methods.