Framework design, initialization and framework usage
Robert M. Münch
robert.muench at saphirion.com
Tue May 7 15:17:53 UTC 2019
On 2019-05-07 09:06:03 +0000, Kagamin said:
> struct myFramework {
> myFrameworkAccessor myFWApp;
> }
>
> interface myFrameworkApp {
> void init();
> }
>
> main(){
> myFramework mf = new myFramework;
>
> mf.myFWApp.init(); // this bombs because myFWApp is NULL
> }
>
> struct myFrameworkAccessor {
> myFrameworkApp instance()
> {
> if(_instance==null)_instance=new myAppCode();
> return _instance;
> }
> myFrameworkApp _instance;
> alias instance this;
> }
>
> class myAppCode : myFrameworkApp {
> void init() {...}
> }
Tried this in a simplex example but get a compile error:
Error: cannot implicitly convert expression `new
myFramework(myFrameworkAccessor(null))` of type `myFramework*` to
`myFramework`
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
More information about the Digitalmars-d-learn
mailing list