Hey, I was wondering if there is a possibility to have a feature added to the compiler.
In RealBASIC, which I otherwise do not really like that much, they have an interesting concept where you can specify that a method is to be called with a "dot syntax".
This ends up looking something like this, as an example I'm currently using standard functions to accomplish:
Then, to call these new "methods", you woulds simply use an existing TMap object, and call the functions as if they were included in the built in definition of TMap:
I think this would also be really handy in developing AI modules, and a lot of other cases more focused on "games", though you might find that once you have this in mind, a lot of possiblities occur to you.
You might ask why don't I just subclass TMap and be done with it? Well, the problem is that existing functions and libraries are going to return TMap objects to me - I can't subclass because there is no way to "cast down the chain". I can't take a TMap and get a TBAMap without copying the object to a new instance of my own class.
Also, this syntax would allow module authors to provide whole packs of functions that would just appear on existing classes (TMap, TGadget, TBank, etc.) without *any* change other than simply Importing the module.
Sounds pretty cool huh?
In RealBASIC, which I otherwise do not really like that much, they have an interesting concept where you can specify that a method is to be called with a "dot syntax".
This ends up looking something like this, as an example I'm currently using standard functions to accomplish:
Function DecodeString(Map Extends TMap, str:String) ... EndFunction Function EncodeString:String(Map Extends TMap) ... EndFunction
Then, to call these new "methods", you woulds simply use an existing TMap object, and call the functions as if they were included in the built in definition of TMap:
Local Data:String = ReadData() Local Values:TMap = New TMap Values.DecodeString(Data) MapInsert(Values, "NewKey", "NewValue") Data = Values.EncodeString() Notify Data
I think this would also be really handy in developing AI modules, and a lot of other cases more focused on "games", though you might find that once you have this in mind, a lot of possiblities occur to you.
You might ask why don't I just subclass TMap and be done with it? Well, the problem is that existing functions and libraries are going to return TMap objects to me - I can't subclass because there is no way to "cast down the chain". I can't take a TMap and get a TBAMap without copying the object to a new instance of my own class.
Also, this syntax would allow module authors to provide whole packs of functions that would just appear on existing classes (TMap, TGadget, TBank, etc.) without *any* change other than simply Importing the module.
Sounds pretty cool huh?