Re: can we detect at compile time module ctor/dtor cycles ?

2013-06-07 Thread Jonathan M Davis
On Friday, June 07, 2013 23:23:25 Timothee Cour wrote: > Why can't we detect at compile time module ctor/dtor cycles (instead of > runtime) ? At minimum, separate compilation stops it. A .di file isn't likely to have them even if its corresponding .d file did. IIRC, there were other reasons as we

can we detect at compile time module ctor/dtor cycles ?

2013-06-07 Thread Timothee Cour
Why can't we detect at compile time module ctor/dtor cycles (instead of runtime) ? See example below. It should be easy to detect the chain at CT: algo: build graph from import dependencies a=>b if module a imports module b. mark as red the modules that have a ctor collapse each non-red node into

Re: std.traits functions causing the compiler to crash

2013-06-07 Thread Eric
On Saturday, 8 June 2013 at 02:32:57 UTC, bearophile wrote: Eric: Yes, the template constraint is much better. However, the compiler still crashes, even with the new code: Because there's a type definition loop, regardless. Using a constraint doesn't change that situation. Bye, bearophile

Re: Derelict linking (Debian + derelict + dmd 2.062)

2013-06-07 Thread mimi
Thanks! It worked! On Saturday, 8 June 2013 at 03:44:22 UTC, Mike Parker wrote: On Saturday, 8 June 2013 at 00:27:36 UTC, mimi wrote: Hi! I am trying to add SDL support to my project. libderelict-dev installed into my Debian and I am just added "import derelict.sdl2.sdl;". And caused: dmd

Re: Derelict linking (Debian + derelict + dmd 2.062)

2013-06-07 Thread Mike Parker
On Saturday, 8 June 2013 at 00:27:36 UTC, mimi wrote: Hi! I am trying to add SDL support to my project. libderelict-dev installed into my Debian and I am just added "import derelict.sdl2.sdl;". And caused: dmd -I/usr/include/dmd/ -unittest -g -debug -debug=osmpbf -L-lDerelictUtil -L-lDereli

Re: Conditional compilation

2013-06-07 Thread Anthony Goins
On Friday, 7 June 2013 at 12:20:23 UTC, finalpatch wrote: string mixins and template mixins don't work either. On Friday, 7 June 2013 at 12:14:45 UTC, finalpatch wrote: Hi folks, I need to apply different calling conventions to the same interfaces when compiling for different platform. It's

Re: std.traits functions causing the compiler to crash

2013-06-07 Thread bearophile
Eric: Yes, the template constraint is much better. However, the compiler still crashes, even with the new code: Because there's a type definition loop, regardless. Using a constraint doesn't change that situation. Bye, bearophile

Re: std.traits functions causing the compiler to crash

2013-06-07 Thread Eric
O import std.traits: hasMember; interface Xidentity(V, K) if (!hasMember!(V, "x")) { } class Foo(K): Xidentity!(Foo!K, K) { K x; } void main() { new Foo!double; } I think it contains a loop at the level of types. In theory the compiler should catch them and give a nice error message.

Re: -profile

2013-06-07 Thread bearophile
Anthony Goins: What is the error here :) 1. dmd profiletest.d should fail because balancedParens is not nothrow even though it is called from a contract. 2. dmd -profile profiletest.d should succeed because nothrow, @safe, pure don't apply to contracts I think -profile and pre-condit

Re: -profile

2013-06-07 Thread bearophile
Anthony Goins: Is this even worth a bug report? http://d.puremagic.com/issues/show_bug.cgi?id=10295 Bye, bearophile

Re: -profile

2013-06-07 Thread Anthony Goins
On Friday, 7 June 2013 at 23:57:37 UTC, bearophile wrote: Anthony Goins: Is this even worth a bug report? Yes, it's worth a bug report in Bugzilla, it's a (small) Phobos Bug. I confirmed its presence. Bye, bearophile Thank you for all your help. Not just here but throughout the forums.

Derelict linking (Debian + derelict + dmd 2.062)

2013-06-07 Thread mimi
Hi! I am trying to add SDL support to my project. libderelict-dev installed into my Debian and I am just added "import derelict.sdl2.sdl;". And caused: dmd -I/usr/include/dmd/ -unittest -g -debug -debug=osmpbf -L-lDerelictUtil -L-lDerelictSDL2 -L-ldl -ofmain libosmpbfd.a math/rtree2d.d mat

Re: opEquals does not work?

2013-06-07 Thread Jonathan M Davis
On Friday, June 07, 2013 14:53:44 Ali Çehreli wrote: > On 06/07/2013 02:18 PM, Jonathan M Davis wrote: > > I have an open pull request as part of the move to getting rid of > > opEquals, > > > opCmp, toHash, and toString from Object, and it would make it so that you > > > could use something oth

Re: -profile

2013-06-07 Thread bearophile
Anthony Goins: Is this even worth a bug report? Yes, it's worth a bug report in Bugzilla, it's a (small) Phobos Bug. I confirmed its presence. Bye, bearophile

Re: -profile

2013-06-07 Thread Anthony Goins
On Friday, 7 June 2013 at 23:42:58 UTC, Anthony Goins wrote: On Friday, 7 June 2013 at 21:39:26 UTC, bearophile wrote: Anthony Goins: Simple question is why? I am compiling this code with -profile, and I don't see errors: import std.string: balancedParens; void main() { assert(balancedP

Re: -profile

2013-06-07 Thread Anthony Goins
On Friday, 7 June 2013 at 21:39:26 UTC, bearophile wrote: Anthony Goins: Simple question is why? I am compiling this code with -profile, and I don't see errors: import std.string: balancedParens; void main() { assert(balancedParens("[[]]", '[', ']')); } Bye, bearophile okay found it

Re: Strange output

2013-06-07 Thread Jesse Phillips
On Friday, 7 June 2013 at 19:10:54 UTC, Daemon wrote: The following program is supposed to print out only numbers that are less than 5, yet the number 63 gets printed. You're probably just playing around, but FYI the function is http://dlang.org/phobos/std_algorithm.html#filter While you've c

Re: opEquals does not work?

2013-06-07 Thread Ali Çehreli
On 06/07/2013 02:18 PM, Jonathan M Davis wrote: > I have an open pull request as part of the move to getting rid of opEquals, > opCmp, toHash, and toString from Object, and it would make it so that you > could use something other than Object: I hope it supports delegate-taking toString overloa

Re: opEquals does not work?

2013-06-07 Thread Namespace
On Friday, 7 June 2013 at 21:42:36 UTC, bearophile wrote: Jonathan M Davis: However, due to D's overload rules, you will _always_ be forced to have an opEquals which takes the most base class that you can compare. http://d.puremagic.com/issues/show_bug.cgi?id=10292 Bye, bearophile Thank y

Re: opEquals does not work?

2013-06-07 Thread bearophile
Jonathan M Davis: However, due to D's overload rules, you will _always_ be forced to have an opEquals which takes the most base class that you can compare. http://d.puremagic.com/issues/show_bug.cgi?id=10292 Bye, bearophile

Re: -profile

2013-06-07 Thread bearophile
Anthony Goins: Simple question is why? I am compiling this code with -profile, and I don't see errors: import std.string: balancedParens; void main() { assert(balancedParens("[[]]", '[', ']')); } Bye, bearophile

Re: opEquals does not work?

2013-06-07 Thread w0rp
On Friday, 7 June 2013 at 21:18:12 UTC, Jonathan M Davis wrote: I have an open pull request as part of the move to getting rid of opEquals, opCmp, toHash, and toString from Object, and it would make it so that you could use something other than Object Oh, that's cool. I didn't know about th

Re: opEquals does not work?

2013-06-07 Thread Jonathan M Davis
On Friday, June 07, 2013 22:51:12 Namespace wrote: > I got it. I must use Object instead of A... How ridiculous. I > thought this was already fixed... I have an open pull request as part of the move to getting rid of opEquals, opCmp, toHash, and toString from Object, and it would make it so that

Re: opEquals does not work?

2013-06-07 Thread w0rp
On Friday, 7 June 2013 at 21:02:15 UTC, Namespace wrote: Yes, I remember. As I heard it the first time I thought it's because of the limited compiler and that it will fixed some day. opEquals for classes is interesting because you actually do need to write 'Object' there because of type poly

Re: opEquals does not work?

2013-06-07 Thread Namespace
On Friday, 7 June 2013 at 20:58:40 UTC, w0rp wrote: On Friday, 7 June 2013 at 20:51:13 UTC, Namespace wrote: I got it. I must use Object instead of A... How ridiculous. I thought this was already fixed... The class opEquals is quite like .equals in Java. You need to match the signature of Obj

Re: opEquals does not work?

2013-06-07 Thread w0rp
On Friday, 7 June 2013 at 20:51:13 UTC, Namespace wrote: I got it. I must use Object instead of A... How ridiculous. I thought this was already fixed... The class opEquals is quite like .equals in Java. You need to match the signature of Object, which is implicitly the base class of all class

Re: -profile

2013-06-07 Thread bearophile
Anthony Goins: Simple question is why? Looks like a little compiler bug. Please create a minimal example that shows the problem. If it's a real problem then it's for Bugzilla. Bye, bearophile

Re: opEquals does not work?

2013-06-07 Thread Namespace
I got it. I must use Object instead of A... How ridiculous. I thought this was already fixed...

opEquals does not work?

2013-06-07 Thread Namespace
Did I miss something? I expected this output opEquals: 23 == 23 Equal 1 opEquals: 23 == 23 Equal 2 by the following code, but I only get this: opEquals: 23 == 23 Equal 2 Code: [code] import std.stdio; class A { public: int id; this(int id) {

-profile

2013-06-07 Thread Anthony Goins
Compiling with -profile and without -release Gives the following error (not exactly but the best I can recall) balancedParens is not nothrow safe pure With -release and -profile all is fine. Builds fine without -profile. Simple question is why?

Re: std.traits functions causing the compiler to crash

2013-06-07 Thread bearophile
Eric: Is this a known problem, or is there a work-around? This is your code reduced a little: import std.traits: hasMember; interface Xidentity(V, K) if (!hasMember!(V, "x")) { } class Foo(K): Xidentity!(Foo!K, K) { K x; } void main() { new Foo!double; } I think it contains a loop a

Re: Strange output

2013-06-07 Thread H. S. Teoh
On Fri, Jun 07, 2013 at 09:10:53PM +0200, Daemon wrote: > The following program is supposed to print out only numbers that are > less than 5, yet the number 63 gets printed. On Fri, Jun 07, 2013 at 09:14:00PM +0200, Daemon wrote: > >auto de = find!(delegate(a) { return a < 5; })([10, 11, 15, 16, >

Re: Strange output

2013-06-07 Thread Daemon
On Friday, 7 June 2013 at 19:47:39 UTC, develop32 wrote: On Friday, 7 June 2013 at 19:10:54 UTC, Daemon wrote: The following program is supposed to print out only numbers that are less than 5, yet the number 63 gets printed. module main; import std.stdio; import std.conv; int main(string[] a

Re: Strange output

2013-06-07 Thread develop32
On Friday, 7 June 2013 at 19:10:54 UTC, Daemon wrote: The following program is supposed to print out only numbers that are less than 5, yet the number 63 gets printed. module main; import std.stdio; import std.conv; int main(string[] argv) { auto de = find!(delegate(a) { return a < 5; })([10

Re: Emplace using private constructor

2013-06-07 Thread develop32
On Friday, 7 June 2013 at 16:14:25 UTC, Ali Çehreli wrote: But it is too heavy-handed. Your problem exposes a real weakness. Other... Well, its not *that* heavy. // Inside Display class. auto display = alloc!Display; display.__ctor(name); Where alloc(T) is a bigger part of the original emplac

std.traits functions causing the compiler to crash

2013-06-07 Thread Eric
mport std.traits; interface Xidentity(V, K) { static if (hasMember!(V, "k")) static assert(0); public int getInstanceCount(); } class X(K) : Xidentity!(X!(K), K) { private K k; X newInstance(K k) { return(new X(k)); } private this(K k) { this.k = k; } public int getInst

Re: Strange output

2013-06-07 Thread Daemon
auto de = find!(delegate(a) { return a < 5; })([10, 11, 15, 16, 27, 20, 2, -4, -17, 8, 64, 6]); Just a clarification, it prints out 64 with the input above, I changed it later just to test it and forgot to update the rest.

Strange output

2013-06-07 Thread Daemon
The following program is supposed to print out only numbers that are less than 5, yet the number 63 gets printed. module main; import std.stdio; import std.conv; int main(string[] argv) { auto de = find!(delegate(a) { return a < 5; })([10, 11, 15, 16, 27, 20, 2, -4, -17, 8, 64, 6]);

Re: Question on class templates

2013-06-07 Thread Eric
On Friday, 7 June 2013 at 18:06:26 UTC, anonymous wrote: On Friday, 7 June 2013 at 17:52:48 UTC, Eric wrote: interface Identity(V, K) { } class X(V, K) : Identity!(V, K) { private K k; public this(K k) { this.k = k; } } void main() { auto x = new X!(X, double)(6.0); } Hi - I have

Re: Learning D

2013-06-07 Thread Gary Willoughby
On Friday, 7 June 2013 at 13:45:50 UTC, Daemon wrote: The only thing that remains is patience I guess. That, buy Andrei's book and ask questions here. :) http://www.amazon.co.uk/The-Programming-Language-Andrei-Alexandrescu/dp/0321635361

Re: Question on class templates

2013-06-07 Thread anonymous
On Friday, 7 June 2013 at 17:52:48 UTC, Eric wrote: interface Identity(V, K) { } class X(V, K) : Identity!(V, K) { private K k; public this(K k) { this.k = k; } } void main() { auto x = new X!(X, double)(6.0); } Hi - I have the code above, but the line in main() gives the follo

Question on class templates

2013-06-07 Thread Eric
interface Identity(V, K) { } class X(V, K) : Identity!(V, K) { private K k; public this(K k) { this.k = k; } } void main() { auto x = new X!(X, double)(6.0); } Hi - I have the code above, but the line in main() gives the following compile error: Error: template instance X!(X, do

Re: Emplace using private constructor

2013-06-07 Thread Ali Çehreli
tldr; I had the crazy idea of mixing-in a specialization of emplace but failed probably because mixin does not respect template constraints. On 06/07/2013 06:50 AM, develop32 wrote: > Nevermind, problem was not worth the question. I just copied code from > Phobos std.conv.emplace and placed it

Re: Emplace using private constructor

2013-06-07 Thread develop32
Nevermind, problem was not worth the question. I just copied code from Phobos std.conv.emplace and placed it directly in my code, it works since it is in the same module as the private constructor.

Re: Learning D

2013-06-07 Thread Daemon
Thanks for all the fantastic replies, now I'm really glad I asked. Ali, I'm already reading your book and it's pretty good. I've also ordered The D Programming language, so that should be a big help. The only thing that remains is patience I guess. I won't give up on D so easily this time. T

Re: Conditional compilation

2013-06-07 Thread Mike Parker
On Friday, 7 June 2013 at 12:14:45 UTC, finalpatch wrote: Hi folks, I need to apply different calling conventions to the same interfaces when compiling for different platform. extern(System) On Windows, it will be seen by the compiler as extern(Windows), elsewhere as extern(C).

Re: Conditional compilation

2013-06-07 Thread finalpatch
string mixins and template mixins don't work either. On Friday, 7 June 2013 at 12:14:45 UTC, finalpatch wrote: Hi folks, I need to apply different calling conventions to the same interfaces when compiling for different platform. It's something like this: OSX: interface InterfaceA : IUnknow

Emplace using private constructor

2013-06-07 Thread develop32
In a project I'm working on there are classes that are available publicly but I want to disable their construction outside of their modules. class Display { const string name; private this(string name) { this.name = name; } static Display[] all() { // Returns all

Conditional compilation

2013-06-07 Thread finalpatch
Hi folks, I need to apply different calling conventions to the same interfaces when compiling for different platform. It's something like this: OSX: interface InterfaceA : IUnknown { extern(C): ... } Windows: interface InterfaceA : IUnknown { ... } I have to add extern(C) on OSX b

Re: geting stack trace from signal handlers

2013-06-07 Thread Timothee Cour
On Fri, Jun 7, 2013 at 12:39 AM, nazriel wrote: > On Thursday, 6 June 2013 at 21:50:58 UTC, Timothee Cour wrote: > >> Great! >> two issues (on OSX at least): >> >> A) >> it seems the top-most element of the call stack gets chopped off; eg in >> your code, the main_module.main symbol will not appe

Re: odd behavior of split() function

2013-06-07 Thread Benjamin Thaut
Am 07.06.2013 09:53, schrieb Bedros: first of all, many thanks for the quick reply. I'm learning D and it's just because of the habit I unconsciously used printf instead of writef thanks again. -Bedros On Friday, 7 June 2013 at 07:29:48 UTC, Jonathan M Davis wrote: On Friday, June 07, 2013 0

Re: odd behavior of split() function

2013-06-07 Thread Bedros
first of all, many thanks for the quick reply. I'm learning D and it's just because of the habit I unconsciously used printf instead of writef thanks again. -Bedros On Friday, 7 June 2013 at 07:29:48 UTC, Jonathan M Davis wrote: On Friday, June 07, 2013 09:18:57 Bedros wrote: I would like

Re: geting stack trace from signal handlers

2013-06-07 Thread nazriel
On Thursday, 6 June 2013 at 21:50:58 UTC, Timothee Cour wrote: Great! two issues (on OSX at least): A) it seems the top-most element of the call stack gets chopped off; eg in your code, the main_module.main symbol will not appear in the stack trace. Any idea why or how to fix that? Is that so

Re: odd behavior of split() function

2013-06-07 Thread Jonathan M Davis
On Friday, June 07, 2013 09:18:57 Bedros wrote: > I would like to split "A+B+C+D" into "A", "B", "C", "D" > > but when using split() I get > > "A+B+C+D", "B+C+D", "C+D", "D" > > > the code is below > > > import std.stdio; > import std.string; > import std.array; > > int main() > { > st

odd behavior of split() function

2013-06-07 Thread Bedros
I would like to split "A+B+C+D" into "A", "B", "C", "D" but when using split() I get "A+B+C+D", "B+C+D", "C+D", "D" the code is below import std.stdio; import std.string; import std.array; int main() { string [] str_list; string test_str = "A+B+C+D"; str_list = test_str.split