| |
| Posted by Amex | PermalinkReply |
|
Amex
| Debugging in Visual D allows one to easily explore the hierarchy of classes.
One problem is being able to easily find other related objects within the hierarchy that might be an ancestor.
It would be very useful to be able to "inject" reference in to Object so that one could add such information that would be available to all objects.
This is more useful in general. Maybe one wants to add common functionality too all objects in the program that Object does not support yet the program was not designed with a base Object. Furthermore, since D is single inheritance it makes it somewhat impossible to use this for the debugging method above since visual D can only show fields.
Idea:
Allow one to extend object. D does not have partial classes, like, say, C#. But for object it would be nice to be able to extend it by some means other than extending recompiling DMD, LDC, GDC.
class Object:Extend
{
int RC = 0;
void Display() { ... }
}
And then RC and Display will be available to all objects.
Display could be a visual inspector for the app's object's and RC could be a resource counter.
I don't care about the specific syntax, just the ability to easily have the functionality(again, without having to fork my own compiler or standard lib).
I don't see why we can't do this, there really are no excuses. I should have full control of my own app and what it can do or not.
I realize that it could cause problems for objects compiled in as a library that would not have such an extension. These are easily dealt with by simply using the new object as the base.
e.g., what we really have is
class Object : Object;
But the base is the original object and the new Object is what is used throughout the app(rather than the base). i.e., we really have
class ObjectNew : Object;
and as if all our classes in code derive from this ObjectNew rather than Object.
There might be a few minor complications but nothing that can't be overcome... Even if it's limited to debugging it would be worth it.
|