Re: Abstractioning away main/winMain

2015-09-07 Thread Kagamin via Digitalmars-d-learn
On Saturday, 5 September 2015 at 01:43:43 UTC, Prudence wrote: Any ideas? See how vibe does it.

Re: Abstractioning away main/winMain

2015-09-05 Thread anonymous via Digitalmars-d-learn
On Saturday 05 September 2015 07:52, anonymous wrote: > This doesn't work because delegates and static initialization don't go > together. You can use a static constructor: > > > const Application MyApp; > static this() > { > Application.New({import std.stdio; std.stdio.writeln("MY APP

Re: Abstractioning away main/winMain

2015-09-04 Thread anonymous via Digitalmars-d-learn
On Saturday 05 September 2015 03:43, Prudence wrote: > Standard and Win32 apps are so old school! > > I'd like to hide WinMain by wrapping it in an application > class(more or less). > > Essentially I have an Application class > > class Application > { > public static Application New(void

Re: Abstractioning away main/winMain

2015-09-04 Thread Alex Parrill via Digitalmars-d-learn
On Saturday, 5 September 2015 at 02:29:05 UTC, Prudence wrote: If I use functions instead of delegates it works. I suppose the problem then is that the delegate can't create a fat pointer when used in a static context. (i.e., why the functions work) The question is, then, Can I construct a

Abstractioning away main/winMain

2015-09-04 Thread Prudence via Digitalmars-d-learn
Standard and Win32 apps are so old school! I'd like to hide WinMain by wrapping it in an application class(more or less). Essentially I have an Application class class Application { public static Application New(void delegate() entry) { } } Another module extern (Windows)

Re: Abstractioning away main/winMain

2015-09-04 Thread Prudence via Digitalmars-d-learn
On Saturday, 5 September 2015 at 01:49:22 UTC, Adam D. Ruppe wrote: On Saturday, 5 September 2015 at 01:43:43 UTC, Prudence wrote: extern (Windows) int WinMain(...) If you use WinMain in D, you'll also have to initialize the D runtime yourself, which will call static constructors and such.

Re: Abstractioning away main/winMain

2015-09-04 Thread Prudence via Digitalmars-d-learn
If I use functions instead of delegates it works. I suppose the problem then is that the delegate can't create a fat pointer when used in a static context. (i.e., why the functions work) The question is, then, Can I construct a delegate manually and supply my own context pointer? e.g.,

Re: Abstractioning away main/winMain

2015-09-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 September 2015 at 01:43:43 UTC, Prudence wrote: extern (Windows) int WinMain(...) If you use WinMain in D, you'll also have to initialize the D runtime yourself, which will call static constructors and such. You'd be better off just using a regular main() function, then