Re: A GUI library to begin with
On Wednesday, 8 February 2012 at 22:21:35 UTC, AaronP wrote: On 02/08/2012 09:24 AM, Jesse Phillips wrote: I think GtkD is stated to suck because it isn't native to Windows or Mac, both in look and availability. Hmm, perhaps. Incidentally, it looks great on Linux! :P GTK+ was created for GIMP which incidentally was made as an open-source alternative for Photoshop that worked correctly for platforms outside of Windows. Linux and FreeBSD just so happen to be large targets here.
Scoped Class Instance
I've been looking into (basic) memory management within D. Through IRC conversation and reading the article on memory management on dlang.org (which seems to be a bit out-of-date), I've concluded that using a global (or static member) function and emplace() in std.conv is a simple solution for providing alternative allocation methods. However, I cannot, by default, scope my custom allocations. Take this for instance: void main() { MyClass inst = alloc!(MyClass)(); inst.do_something(); dealloc(inst); } Now, I want my dealloc function to be called automagically. One safe measure is: void main() { MyClass inst = alloc!(MyClass)(); scope(exit) dealloc(inst); inst.do_something(); } But I'm lazy and I'm looking for shorter methods. void main() { mixin AutoRef(MyClass, inst); inst.do_something(); } Any ideas?
Re: Scoped Class Instance
On Tuesday, 31 January 2012 at 15:19:00 UTC, Trass3r wrote: However, I cannot, by default, scope my custom allocations. Any ideas? std.typecons.scoped I looked into this and I'm unsure of its exact use. It says, Allocates a class object right inside the current scope which doesn't really define how it's allocated nor does it explain how this would work with custom de/allocators. Also, it claims it avoids the overhead of new of which I'm not entirely sure of what it means. Could some clarification be made?
std.parallelism: TaskPool adjustment
I'm wanting to change the number of worker threads post creation of my TaskPool instance. I see nothing that allows me to do this. Isn't that abnormal for a thread pool?
Class Initialization
In C++, they provide a mechanism to initialize class variables to a passed value. class Test { int bob; public: Test(int jessica) : bob(jessica) { } }; The above basically says int this.bob = jessica; as opposed to this: class Test { int bob; public: Test(int jessica) { bob = jessica; } }; which basically says int this.bob = void; bob = jessica;. Now, I'm not a speed freak but this is a quick and should be a painless optimization. D allows defaults set by the class but cannot seem to find anything to allow me variable initialization values. Not that it's that big of a deal but am I missing something?
Re: Calling a C++ Object from D
On Tuesday, 24 January 2012 at 12:30:26 UTC, David Eagen wrote: I'm trying to understand how to call a C++ library from D. Specifically, the Windows Update API. My goal is rather simple in that I want to detect whether there is a reboot pending for the system. To do that I need to call the ISystemInformation::RebootRequired property but I don't know how to do that in D. Information about the call is at http://msdn.microsoft.com/en-us/library/aa386098(v=vs.85).aspx. I have the C++ header and have successfully defined VARIANT_BOOL, VARIANT_TRUE, and VARIANT_FALSE. The last bit to do is to define the ISystemInterface object itself and the RebootRequired method. How do I do that? -Dave From what I understand, the most reliable way currently is to wrap the C++ API in a C API and then call the C API from D. It's easy but time consuming and can't be generated currently.
Re: for loop
On 01/22/2012 11:08 AM, bearophile wrote: Max Klyga: If you want to declare and initialize several variables in the for loop, you can do it if they are of the same type: for (int x = 0, y = 0; ...; .++x, ++y) { ... } And if you need different types this sometimes is enough: void main() { for (auto x = 0, y = 0.0; x 10; x++, y++) { } } Bye, bearophile This is an ugly solution (and I'm not 100% sure it's valid D) but: /+/ void main() { { short y = 0; int x = 0; for (; x 10; ++x, ++y) { } } } /+/
Re: for loop
On 01/22/2012 11:37 AM, Zachary Lund wrote: On 01/22/2012 11:08 AM, bearophile wrote: Max Klyga: If you want to declare and initialize several variables in the for loop, you can do it if they are of the same type: for (int x = 0, y = 0; ...; .++x, ++y) { ... } And if you need different types this sometimes is enough: void main() { for (auto x = 0, y = 0.0; x 10; x++, y++) { } } Bye, bearophile This is an ugly solution (and I'm not 100% sure it's valid D) but: /+/ void main() { { short y = 0; int x = 0; for (; x 10; ++x, ++y) { } } } /+/ LOL, well... I missed the post that said the exact same thing I did. Oh well...