I give up.
Either I can't explain the benefits of interfaces or you can't understand them. Probably a mixture of both.
It would be a different matter if you understood them but could mount an argument that they are not necessary or desirable in BM.
Like trying to explain the concept of Blue to somebody who can only see in Red and Green. You keep thinking that Blue and all of the colours with a component of Blue are just combinations of Red and Green.
In max2d.bmx the only reference that I can see to what you refer to as 'TMax2DGraphicsDriver (g)' is 'TMax2DGraphics(g)' in the Graphics function partially shown below.
It is not a creator.
It is a cast of variable g which is declared and initialised in the first statement shown. If in the inheritence path of g there is a type TMax2dGraphics then the cast returns the instance of that type, otherwise it returns Null.
So unless you have another bit of code in mind I think you'll have to agree that it is a cast ?
First time I saw somthing like this I did a double take myself as I'm more familiar with a cast such as '(TMax2DGraphics)g' which is the inverse syntax or a compatibility test such as 'if (g is TMax2DGraphics) ...'.
BTW - You can see some of the internals of BM dealing with types and how this cast works in file BlitzMax\mod\brl.mod\blitz.mod\blitz_object.c
A very neat walk up the inheritence chain.
I find this bit of BM syntax a bit strange but hey it is consistent and it works. If you learnt BM first then tried say C# you'd wonder why it was so strange !
Peace Dreamora.
Either I can't explain the benefits of interfaces or you can't understand them. Probably a mixture of both.
It would be a different matter if you understood them but could mount an argument that they are not necessary or desirable in BM.
Like trying to explain the concept of Blue to somebody who can only see in Red and Green. You keep thinking that Blue and all of the colours with a component of Blue are just combinations of Red and Green.
In max2d.bmx the only reference that I can see to what you refer to as 'TMax2DGraphicsDriver (g)' is 'TMax2DGraphics(g)' in the Graphics function partially shown below.
It is not a creator.
It is a cast of variable g which is declared and initialised in the first statement shown. If in the inheritence path of g there is a type TMax2dGraphics then the cast returns the instance of that type, otherwise it returns Null.
Function Graphics( width,height,depth=16,hertz=60 ) ... Local g:TGraphics=CreateDisplayGraphics( width,height,depth,hertz,0 ) If Not g Throw "Unable to create graphics" EndIf displayGraphics=TMax2DGraphics(g) If Not displayGraphics g.Close Throw "Current graphics driver is not a Max2D driver" EndIf ... End Function
So unless you have another bit of code in mind I think you'll have to agree that it is a cast ?
First time I saw somthing like this I did a double take myself as I'm more familiar with a cast such as '(TMax2DGraphics)g' which is the inverse syntax or a compatibility test such as 'if (g is TMax2DGraphics) ...'.
BTW - You can see some of the internals of BM dealing with types and how this cast works in file BlitzMax\mod\brl.mod\blitz.mod\blitz_object.c
... BBObject *bbObjectDowncast( BBObject *o,BBClass *t ){ BBClass *p=o->clas; while( p && p!=t ) p=p->super; return p ? o : &bbNullObject; } ...
A very neat walk up the inheritence chain.
I find this bit of BM syntax a bit strange but hey it is consistent and it works. If you learnt BM first then tried say C# you'd wonder why it was so strange !
Peace Dreamora.