A short article about one of the many features Spring4D 1.2 will contain.
A short article about one of the many features Spring4D 1.2 will contain.
http://delphisorcery.blogspot.com/2015/01/smart-pointers-in-delphi.html
http://delphisorcery.blogspot.com/2015/01/smart-pointers-in-delphi.html
Well done, Stefan. i guess this feature can be used without too much dependency of the entire spring4d?
ReplyDeleteEdwin Yip Yes, it's defined in Spring.pas which has just a dependency on 3 other Spring.Base units. Just as most basic types defined in Spring4D. It's one of our goals to not pull in the entire library for basic functionalities.
ReplyDeleteStefan Glienke I'm currently using this simple unit by SO user CodeAndCats: http://stackoverflow.com/questions/415958/how-to-automatically-free-classes-objects/418206#418206
ReplyDeleteEdwin Yip That works but is only the solution to a part of the problem that smart pointers solve. It would solve what I showed in my examples but in fact you can pass a smart pointer around, keep them and then at the end somewhere they destroy the instance when they run out of scope.
ReplyDeleteStefan Glienke Thanks for the explanation, so basically it's like the reference-counted interface instances, right?
ReplyDeleteNot only like, it is an interface, so it is reference counted, yes.
ReplyDelete