Using legacy types
BlitzMax Forums/BlitzMax Beginners Area/Using legacy types
| ||
Does anyone use the legacy types as setup in bbtype.bmx in anything but converted code ? Seems pretty easy to roll with coming from Blitz3D , but was wondering if there's any extra benefit to not using it. |
| ||
Two big ones: -- it breaks the type system (can't use Strict) -- it breaks the garbage collector A converted project hopefully already has functioning memory management written into it, and doesn't engage too many type errors, but it will make it rather difficult to expand your project further in a safe fashion. The substitute for Blitz Classic's Object/Handle system is to simply assign an object to an integer variable and let the compiler create an int reference automatically; since the compiler can no longer track the pointer, this locks the object out from the garbage collector until it is manually returned to it with Release. Turning this "feature" off is one of the big wins of Strict mode, since (being automatic whenever you assign between ints and objects) it's so incredibly easy to introduce bugs through it. There is no real reason to be using Object/Handle style code in BlitzMax anyway; the limitations of Blitz Classic that required it have been eliminated. The automatic typelist also breaks garbage collection, since objects aren't able to be collected as long as the whole type has a reference to them. The automatic type list is a bit of a waste of memory in most cases. So I would say that using these in newly-written code is a terrible idea, because you don't get to take advantage of some of BlitzMax's most important new features. If you have a good reason to want similar functionality, I suggest rethinking why you want it and then rebuilding the necessary support code yourself, to suit your project. As a PS: if you're converting and rewriting/expanding a huge Classic codebase, remember that you can split BlitzMax code up into separate compilation units (Import instead of Include). Imported units can be made Strict and so on independently of the rest of the program, so you can "clean it up" piece by easily-rewritten piece until all of your program support is good BlitzMax, and then tackle the main program logic. |
| ||
Thanks, so it would be better when converting to go from thisType bbEmitterPath Extends TBBType Method New() Add(EmitterPath_list) End Method Method After:bbEmitterPath() Local t:TLink t=_link.NextLink() If t Return bbEmitterPath(t.Value()) End Method Method Before:bbEmitterPath() Local t:TLink t=_link.PrevLink() If t Return bbEmitterPath(t.Value()) End Method To this for converted types Type EmitterPath Field _list:TList Field _link:TLink Method Add(t:TList) _list=t _link=_list.AddLast(Self) End Method Method InsertBefore(t:EmitterPath) _link.Remove _link=_list.InsertBeforeLink(Self,t._link) End Method Method InsertAfter(t:Emitterpath) _link.Remove _link=_list.InsertAfterLink(Self,t._link) End Method Method Remove() _list.remove Self End Method Method New() Add(EmitterPath_list) End Method Method After:EmitterPath() Local t:TLink t=_link.NextLink() If t Return emitterpath(t.Value()) End Method Method Before:EmitterPath() Local t:TLink t=_link.PrevLink() If t Return emitterpath(t.Value()) End Method |