Re: char[] ported from C to char[0] in the D core library

2015-09-10 Thread badlink via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 19:37:54 UTC, Alex Parrill wrote: It's a flexible array member [1], not a pointer. Changing it to `char*` would make it incompatible with the C functions using it. [1]: https://en.wikipedia.org/wiki/Flexible_array_member TIL a new detail about C on the D for

Re: Hello World Example with Glade?

2015-09-10 Thread Mike James via Digitalmars-d-learn
On Friday, 11 September 2015 at 06:45:07 UTC, Mike McKee wrote: On Friday, 11 September 2015 at 06:00:39 UTC, Mike McKee wrote: [...] I think the start of this probably looks like the following, but I'm not certain: import gtk; import gobject.Type; import std.stdio; import std.c.process; i

Re: Hello World Example with Glade?

2015-09-10 Thread Mike McKee via Digitalmars-d-learn
On Friday, 11 September 2015 at 06:00:39 UTC, Mike McKee wrote: On Ubuntu Linux, I can draw a simple Hello World interface (and a button on it to close the window) with Glade and save the file. Now how do I use GtkD and D to load that interface? Anyone got a super simple tutorial for that? I

Re: How To: Passing curried functions around

2015-09-10 Thread Ali Çehreli via Digitalmars-d-learn
On 09/06/2015 12:05 PM, Bahman Movaqar wrote: > alias bool function(int n) validator_t; There is the relatively newer alias syntax which is more intuitive: alias Validator = bool function(int n); > bool isEven(int n) { ... } > bool isPrime(int n) { ... } > /** > * keep

Hello World Example with Glade?

2015-09-10 Thread Mike McKee via Digitalmars-d-learn
On Ubuntu Linux, I can draw a simple Hello World interface (and a button on it to close the window) with Glade and save the file. Now how do I use GtkD and D to load that interface? Anyone got a super simple tutorial for that?

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, LPARAM)

Re: Version for windows/console compilation?

2015-09-10 Thread Mike Parker via Digitalmars-d-learn
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 the windows gui subsystem with a linker flag. Specifically, add

Re: private selective import not so private ?

2015-09-10 Thread BBasile via Digitalmars-d-learn
On Friday, 11 September 2015 at 00:55:41 UTC, Adam D. Ruppe wrote: On Friday, 11 September 2015 at 00:52:00 UTC, BBasile wrote: While trying to get why some call to memmove without the right import didn't lead to a compilation failure i've found that imported symbols are not private ! Is that a

Re: private selective import not so private ?

2015-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 00:52:00 UTC, BBasile wrote: While trying to get why some call to memmove without the right import didn't lead to a compilation failure i've found that imported symbols are not private ! Is that a bug ? The specs don't say that a selective import is public ! Ye

Re: shared array?

2015-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
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, LPARAM)[] callbacks; my guess is the Array library thing isn't marked as s

private selective import not so private ?

2015-09-10 Thread BBasile via Digitalmars-d-learn
While trying to get why some call to memmove without the right import didn't lead to a compilation failure i've found that imported symbols are not private ! Is that a bug ? The specs don't say that a selective import is public ! -- other.d -- module other; private import core.stdc.string: mem

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 don

Re: Can we get a video tutorial?

2015-09-10 Thread Stephen via Digitalmars-d-learn
On Friday, 4 September 2015 at 16:11:59 UTC, Stephen wrote: On Friday, 4 September 2015 at 05:51:02 UTC, Mike Parker wrote: * What was previously said * * Bump * Hopefully I'm allowed to bump this...?

Re: Version for windows/console compilation?

2015-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 10 September 2015 at 18:06:43 UTC, Prudence wrote: Is there a flag for knowing when a project is compiling for windows(Uses WinMain) vs a console(normal main)? You'd have to choose the main yourself anyway, so document what process you use for that for people to use. BTW it is p

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 to

Calling D from C, C++, Python…

2015-09-10 Thread Russel Winder via Digitalmars-d-learn
Is there an easy way of knowing when you do not have to initialize the D runtime system to call D code from, in this case, Python via a C adapter? I naïvely transformed some C++ to D, without consideration of D runtime systems, compiled it and it all worked. Which is good, but… -- Russel. ==

Re: Detecting premature end of spawned threads with std.concurrency

2015-09-10 Thread Ali Çehreli via Digitalmars-d-learn
On 09/03/2015 02:20 PM, Matt Kline wrote: > neither the docs nor the current Phobos implementation > make any mention of such exceptions. There is LinkTerminated but you must use spawnLinked(): http://dlang.org/phobos/std_concurrency.html#.LinkTerminated http://ddili.org/ders/d.en/concurren

Re: Sum and other algorithm functions

2015-09-10 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 10 September 2015 at 13:48:16 UTC, Namal wrote: Hello, how can I define the range for the sum function which I want to sum up? For instance how do I sum up the first 3 elements of an array int[] a = [1,2,3,4,5,6,7,8,9]; or the last 3? In this case, you can simply slice array

Re: Sum and other algorithm functions

2015-09-10 Thread anonymous via Digitalmars-d-learn
On Thursday 10 September 2015 15:48, Namal wrote: > Hello, > > how can I define the range for the sum function which I want to > sum up? For instance how do I sum up the first 3 elements of an > array > > int[] a = [1,2,3,4,5,6,7,8,9]; > > or the last 3? First you slice the first/last 3, the

Sum and other algorithm functions

2015-09-10 Thread Namal via Digitalmars-d-learn
Hello, how can I define the range for the sum function which I want to sum up? For instance how do I sum up the first 3 elements of an array int[] a = [1,2,3,4,5,6,7,8,9]; or the last 3?

Re: friends with phobos, workaround?

2015-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 10 September 2015 at 08:22:29 UTC, Daniel N wrote: this(string caller = __MODULE__)(int val) if(caller == "std.conv") // Use scoped!Awesome That's disgustingly genius. I'm a bit jealous I didn't think of it myself! One slight problem though: you couldn't call super() from

Re: friends with phobos, workaround?

2015-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 23:44:14 UTC, Idan Arye wrote: public: mixin MakeUnique!(int); I actually think that should be a free function in the module because then it can be used by derived classes too without having to mix it in each of them as well.

Re: What is the difference between D and C++ regarding Unique, RefCounted and Scoped?

2015-09-10 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 10 September 2015 at 12:34:54 UTC, Daniel Kozák wrote: On Thu, 10 Sep 2015 11:38:35 + "Gary Willoughby" wrote: On Wednesday, 9 September 2015 at 23:22:49 UTC, ponce wrote: > - RefCounted > > Only for D structs. std::shared_ptr works for all. RefCounted works with classes as

Re: What is the difference between D and C++ regarding Unique, RefCounted and Scoped?

2015-09-10 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 10 Sep 2015 11:38:35 + "Gary Willoughby" wrote: > On Wednesday, 9 September 2015 at 23:22:49 UTC, ponce wrote: > > - RefCounted > > > > Only for D structs. std::shared_ptr works for all. > > RefCounted works with classes as well. > > http://dlang.org/phobos/std_typecons.html#.RefCo

Re: using std.algorithm to find intersection of DateTime[][] arg

2015-09-10 Thread deed via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 20:28:35 UTC, Laeeth Isharc wrote: I have a DateTime[][] arg ... I would like to find the intersection of the dates. A suggestion: auto minLength = arg.map!(a => a.length).reduce!min; auto minIdx = arg.map!(a => a.length).countUntil(minLength); a

Re: What is the difference between D and C++ regarding Unique, RefCounted and Scoped?

2015-09-10 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 23:22:49 UTC, ponce wrote: - RefCounted Only for D structs. std::shared_ptr works for all. RefCounted works with classes as well. http://dlang.org/phobos/std_typecons.html#.RefCounted

Re: ref parameter qualifier and static arrays

2015-09-10 Thread Paul via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 20:35:53 UTC, anonymous wrote: When you pass a slice (without ref), what's actually passed is a pointer and length. The contents are not copied. That means, when you alter an array element, the change will be done the original, even without ref: Thanks both.

Re: friends with phobos, workaround?

2015-09-10 Thread Daniel N via Digitalmars-d-learn
On Thursday, 10 September 2015 at 08:22:29 UTC, Daniel N wrote: import std.typecons; class Awesome1 { private: int val; this(string caller = __MODULE__)(int val) if(caller == "std.conv") // Use scoped!Awesome { this.val = val; } } class Awesome2 { private: int val; this(st

Re: friends with phobos, workaround?

2015-09-10 Thread Daniel N via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 23:44:14 UTC, Idan Arye wrote: How about using a mixin template(http://dlang.org/template-mixin.html)? Thanks, it's a good solution. My only reservation is I would prefer to find a way to directly invoke a symbol in std.* as otherwise different frameworks m

Re: Status of Win32 C++ interop

2015-09-10 Thread Benjamin Thaut via Digitalmars-d-learn
On Tuesday, 8 September 2015 at 12:56:00 UTC, Laeeth Isharc wrote: This is really very clear and helpful, and I appreciate your taking the time. I will place it on the wiki if that's okay. Thats ok. Library support is surely one of the largest impediments to the adoption of D, and we ou