TOPIC: Adding methods to Object class causes crash
#460
Adding methods to Object class causes crash 3 Years, 8 Months ago
For the Object data type, the user manual states:

Additional, user defined methods can be added by defining a class called "Objects".
But, when I create an Objects class in the library, Suneido goes in crash...

P.S.: do not try to create an Objects class if you have not backed up the 'suneido.db' file. I don't know why, but to me the rebuild has not worked. Luckily I have recovered the suneido.db with an hex editor.
 
 
Mauro
 
#482
Re:Adding methods to Object class causes crash 3 Years, 8 Months ago
One reason creating an Objects in your own library may cause a crash is that it is replacing the one in stdlib, which means you lose all the methods from the stdlib one, and since these methods are used by the IDE, you crash.

You can do it by making the Objects in your own library inherit/derive from the "previous" one:

Code:

_Objects
    {
    MyMethod()
        {
        return 123
        }
    }



You still have to be very careful because if you "break" it, you will probably crash. (This is similar to modifying a "basic" class like Control or Window.)

Normally, I would not recommend doing this because it will make your code harder to read/understand because of not knowing where the methods are coming from.
 
 
andrew
 
#485
Re:Adding methods to Object class causes crash 3 Years, 8 Months ago
Ok, thank you for the suggestions.
I think that should be written in the User's Manual that when one would add a method to a builtin class as Object, Number, etc., it is advisable to derive from previous class with the '_' char (_Objects, _Numbers, etc.).
 
 
Mauro