Re: Initalizing complex array types or some other problem ;/

2015-09-15 Thread Prudence via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 20:54:49 UTC, anonymous wrote: On Tuesday 15 September 2015 22:09, Prudence wrote: The code below doesn't work. Please be more specific in how it doesn't work. Mention the error message if there is one, or say how the code behaves differently from what

Initalizing complex array types or some other problem ;/

2015-09-15 Thread Prudence via Digitalmars-d-learn
How does one initialize a tuple type and are arrays initialized by default? The code below doesn't work. I recently converted to use a tuple and that seemed to have broke it and I don't know why, when I changed the New function to use a ref, that made it worse cause now the array is all

Convert array to tupled array easily?

2015-09-14 Thread Prudence via Digitalmars-d-learn
I created the following code that some of you have already seen. It's sort of a multiple value AA array with self tracking. The problem is, that for some type values, such as delegates, the comparison is is identical. (basically when the delegate is the same) To solve that problem, I'd like

Re: shared array?

2015-09-13 Thread Prudence via Digitalmars-d-learn
On Sunday, 13 September 2015 at 16:58:22 UTC, Ola Fosheim Grøstad wrote: On Sunday, 13 September 2015 at 15:35:07 UTC, Jonathan M Davis wrote: the GC heavily. And the reality of the matter is that the vast majority of programs will have _no_ problems with using the GC so long as they don't use

Re: shared array?

2015-09-13 Thread Prudence via Digitalmars-d-learn
On Sunday, 13 September 2015 at 17:16:02 UTC, ponce wrote: On Sunday, 13 September 2015 at 17:00:30 UTC, Ola Fosheim Grøstad wrote: On Sunday, 13 September 2015 at 16:53:20 UTC, ponce wrote: GC is basically ok for anything soft-realtime, where you already spend a lot of time to go fast enough.

Re: Mixin templates accessing mixed out scope

2015-09-12 Thread Prudence via Digitalmars-d-learn
On Saturday, 12 September 2015 at 17:11:04 UTC, anonymous wrote: On Saturday 12 September 2015 16:30, Ali Çehreli wrote: Reduced: [...] Error: type SingleStore is not an expression Reduced further: class MyStore { class SingleStore { static void New() // Removing

Re: Mixin templates accessing mixed out scope

2015-09-12 Thread Prudence via Digitalmars-d-learn
On Saturday, 12 September 2015 at 14:30:16 UTC, Ali Çehreli wrote: On 09/12/2015 06:37 AM, Prudence wrote: Says the creating new SingleStore is not an expression Reduced: mixin template ObjectStore(TKey) { class SingleStore { static void New()// Removing 'static'

Does a synchronization yield on waiting thread?

2015-09-12 Thread Prudence via Digitalmars-d-learn
It would seem to be the logical thing to do? That is, suppose two threads are sharing a resource. Thread A has it locked. B is "waiting". Is B in a loop burning cycles running in the background(regardless of thread.sleep, which only alleviates the problem) or does it yield completely and

Re: shared array?

2015-09-12 Thread Prudence via Digitalmars-d-learn
On Saturday, 12 September 2015 at 06:23:12 UTC, Jonathan M Davis wrote: On Friday, September 11, 2015 23:29:05 Laeeth Isharc via Digitalmars-d-learn wrote: On Friday, 11 September 2015 at 21:58:28 UTC, Adam D. Ruppe wrote: > [...] Seems to be quite a lot of FUD wrt use of standard library and

Mixin templates accessing mixed out scope

2015-09-12 Thread Prudence via Digitalmars-d-learn
The following code simply does not work, it might be buggy now after fiddling with it but basically remove and the SingleStore.New are not working(Says the creating new SingleStore is not an expression, which makes no sense to me). Essentially I'm creating a mixin template so I can have

Re: shared array?

2015-09-11 Thread Prudence via Digitalmars-d-learn
On Friday, 11 September 2015 at 16:04:22 UTC, Kagamin wrote: On Friday, 11 September 2015 at 14:54:00 UTC, Prudence wrote: But in this case it is static, so why does it matter? Do you have any ideas how to wrap it or fix this? It matters exactly because it is static. A code written for

Re: shared array?

2015-09-11 Thread Prudence via Digitalmars-d-learn
On Friday, 11 September 2015 at 19:27:49 UTC, Adam D. Ruppe wrote: On Friday, 11 September 2015 at 17:29:47 UTC, Prudence wrote: I don't care about "maybe" working. Since the array is hidden inside a class I can control who and how it is used and deal with the race conditions. You could use

Re: shared array?

2015-09-11 Thread Prudence via Digitalmars-d-learn
On Friday, 11 September 2015 at 20:30:37 UTC, Adam D. Ruppe wrote: On Friday, 11 September 2015 at 20:06:53 UTC, Prudence wrote: Can you back up this claim? Not saying your lying, I'd just like to know it's true for a fact? The list of things that trigger the GC is pretty short. See the

Multidimension AA's and remove

2015-09-11 Thread Prudence via Digitalmars-d-learn
Error: template std.algorithm.mutation.remove cannot deduce function from argument types !()(bool delegate(void*, uint, uint, int)[], void), candidates are: std.algorithm.mutation.remove(SwapStrategy s = SwapStrategy.stable, Range, Offset...)(Range range, Offset offset) if (s !=

Re: shared array?

2015-09-11 Thread Prudence via Digitalmars-d-learn
On Friday, 11 September 2015 at 13:12:14 UTC, Adam D. Ruppe wrote: On Friday, 11 September 2015 at 04:28:52 UTC, Prudence wrote: I thought about that but then I have to rely on the GC for some simple things. Doesn't seem like the right way to go. Since it is static, it will never be collected

Re: shared array?

2015-09-11 Thread Prudence via Digitalmars-d-learn
On Friday, 11 September 2015 at 07:41:10 UTC, Kagamin wrote: I get only one error: Error: non-shared method std.container.array.Array!(void delegate()).Array.~this is not callable using a shared object. It will try to destruct the array on program termination, but it requires the destructor

Version for windows/console compilation?

2015-09-10 Thread Prudence via Digitalmars-d-learn
Is there a flag for knowing when a project is compiling for windows(Uses WinMain) vs a console(normal main)? version(Windows) is always valid for a console app, so it is useless to disambiguate between a console app and a windows app. (Say I have both a main and a winmain in my code, I need

shared array?

2015-09-10 Thread Prudence via Digitalmars-d-learn
I can't create a shared array: static Array!(bool delegate(int, WPARAM, LPARAM)) callbacks; (prepending shared produce a ton of errors with the Array class) I've tried making it a pointer and other things. The array must be static and must be shared. Without shared everything works but I

Re: Version for windows/console compilation?

2015-09-10 Thread Prudence via Digitalmars-d-learn
On Friday, 11 September 2015 at 01:36:31 UTC, Mike Parker wrote: On Thursday, 10 September 2015 at 18:10:43 UTC, Adam D. Ruppe wrote: BTW it is pretty rare that you should actually write a WinMain in D. The right thing to do in most cases is to write a normal main function. You can still get

Re: shared array?

2015-09-10 Thread Prudence via Digitalmars-d-learn
On Friday, 11 September 2015 at 00:50:15 UTC, Adam D. Ruppe wrote: On Friday, 11 September 2015 at 00:48:28 UTC, Prudence wrote: static Array!(bool delegate(int, WPARAM, LPARAM)) callbacks; Try just using a regular array instead of the library Array. static bool delegate(int, WPARAM,

Concurency wtf?

2015-09-08 Thread Prudence via Digitalmars-d-learn
I can't seem to receive certain messages, my code is very simple and it all works except for receiving: in one thread I do locate("MyMonitor").send(cast(shared)pt); which sends the message(pt is a windows POINT structure). In the MyMonitor spawned thread, I have while

Win32 function vs delegate issues with api

2015-09-08 Thread Prudence via Digitalmars-d-learn
I have hook = SetWindowsHookEx(WH_MOUSE, , NULL, ThreadID); Proc is the standard hook proc: public extern (Windows) LRESULT Proc(int code, WPARAM wParam, LPARAM lParam) I get a type mismatch because Proc is a delegate and SetWindowsHookEx expects a function. Making proc static works but

Re: Windows Header consts

2015-09-07 Thread Prudence via Digitalmars-d-learn
On that note, is there also any generic translation software for code that you can program a set of simple "rules"(matching and arranging) to translate source code? e.g., match("const WM_", ";")->WM.add(%1 + ",")). The above should be obvious but essentially it matches the first string until

Windows Header consts

2015-09-07 Thread Prudence via Digitalmars-d-learn
Windows headers contain a ton of global const's for the various messages. Seems like a very bad way to go about this. Could one not simply put all these in an enum? e.g., enum WM { WM_CREATE = 1, etc... }? If so, because there are so many and so many references to them, this can't be done

Re: Windows Header consts

2015-09-07 Thread Prudence via Digitalmars-d-learn
On Monday, 7 September 2015 at 20:55:25 UTC, Adam D. Ruppe wrote: On Monday, 7 September 2015 at 19:06:48 UTC, Prudence wrote: It's called encapsulation. It prevents namespace pollution and identifier collision. This is already provided by the D module system. Even if you were to define a

Re: Windows Header consts

2015-09-07 Thread Prudence via Digitalmars-d-learn
On Monday, 7 September 2015 at 22:21:28 UTC, Adam D. Ruppe wrote: On Monday, 7 September 2015 at 22:02:47 UTC, Prudence wrote: Oh, and who says you couldn't keep both systems? Nobody. There's absolutely nothing stopping you from defining your one constants and bindings. I think you should

Re: Windows Header consts

2015-09-07 Thread Prudence via Digitalmars-d-learn
On Monday, 7 September 2015 at 17:59:43 UTC, Adam D. Ruppe wrote: On Monday, 7 September 2015 at 17:44:54 UTC, Prudence wrote: const WM_* -> add to enum WM; else WM_* -> WM.* I'm against that. The documentation all says WM_* and we shouldn't muck with it. huh? Are you saying you don't

Re: Windows Header consts

2015-09-07 Thread Prudence via Digitalmars-d-learn
On Monday, 7 September 2015 at 18:58:08 UTC, Adam D. Ruppe wrote: On Monday, 7 September 2015 at 18:42:59 UTC, Prudence wrote: because it is confusing and hard for you to understand over Nope, I'm saying it is a pointless change. If you do that, EVERY time you want to look something up, you

Re: Interface "indexing"

2015-09-06 Thread Prudence via Digitalmars-d-learn
On Sunday, 6 September 2015 at 18:11:44 UTC, Kagamin wrote: Well, you can have an array of event factories: IEvent function()[2] factories = [ factory1, factory2 ]; IEvent factory1() { return new Event1(); } IEvent factory2() { return new Event2(); } Then use enum for indexing: IEvent e =

Re: Windows Resources

2015-09-06 Thread Prudence via Digitalmars-d-learn
On Sunday, 6 September 2015 at 10:28:59 UTC, Kagamin wrote: On Sunday, 6 September 2015 at 02:37:21 UTC, Prudence wrote: Obviously the issue is that I'm not using any resources yet it is giving me such an error. You do. See docs for lpszMenuName field. GUI projects generated by Visual Studio

Create a delegate function

2015-09-05 Thread Prudence via Digitalmars-d-learn
I have code setup in such a way that I call a user defined function, e.g., void myFunc(Data d) { } myFunc has to be passed to the main code using something like void SetFunc(void function(Data) func) { ... func(myData); } What I would like to do is, instead of having to pass data to

Windows Resources

2015-09-05 Thread Prudence via Digitalmars-d-learn
I'm trying to create a win32 window. I coped the code pretty much directly from msdn: MSG msg; BOOL bRet; WNDCLASS wc; // Register the window class for the main window. if (!hPrevInstance) {

Re: Windows Resources

2015-09-05 Thread Prudence via Digitalmars-d-learn
On Sunday, 6 September 2015 at 00:29:13 UTC, Adam D. Ruppe wrote: On Saturday, 5 September 2015 at 19:06:15 UTC, Prudence wrote: That's about as far as I can get. (what resource data? Where I do put it? How, who, when?) Resource data in Windows is data compiled into your exe. It is stuff

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.,