Re: Nested C++ namespace library linking

2015-01-20 Thread Guillaume Chatelet via Digitalmars-d-learn
That's what I thought. I reported this bug a while ago but it didn't get a lot of attention. https://issues.dlang.org/show_bug.cgi?id=13337

Re: Nested C++ namespace library linking

2015-01-20 Thread Paul O'Neil via Digitalmars-d-learn
On Tuesday, 20 January 2015 at 21:10:59 UTC, Guillaume Chatelet wrote: Consider the following foo.cpp namespace A { namespace B { struct Type {}; int foo(Type unused){ return 42; } } } Compile it : g++ foo.cpp -c -o foo.o Then the following main.d extern(C++, A.B) { struct Type {} int

Nested C++ namespace library linking

2015-01-20 Thread Guillaume Chatelet via Digitalmars-d-learn
Consider the following foo.cpp namespace A { namespace B { struct Type {}; int foo(Type unused){ return 42; } } } Compile it : g++ foo.cpp -c -o foo.o Then the following main.d extern(C++, A.B) { struct Type {} int foo(Type unused); } void main() { foo(Type()); } Compile it : dmd m

Re: Memory error when using a template in a class destructor

2015-01-20 Thread ketmar via Digitalmars-d-learn
On Tue, 20 Jan 2015 17:59:38 + JC via Digitalmars-d-learn wrote: > The following code throws a > core.exception.InvalidMemoryOperationError@(0), anyone have an > idea of what is causing it? > > --- > > import std.stdio; > > class Test > { > this() > { > struct S

Memory error when using a template in a class destructor

2015-01-20 Thread JC via Digitalmars-d-learn
The following code throws a core.exception.InvalidMemoryOperationError@(0), anyone have an idea of what is causing it? --- import std.stdio; class Test { this() { struct Start { string filename; }

Re: rebind of const class variables

2015-01-20 Thread ketmar via Digitalmars-d-learn
On Tue, 20 Jan 2015 14:45:26 + bearophile via Digitalmars-d-learn wrote: > ketmar: > > > Jonathan explains it very well. i can add the only thing: don't > > use `const` until you forced to. ;-) > > In D use immutable (or const) everywhere you can. Possibly mark > as immutable everything d

Re: rebind of const class variables

2015-01-20 Thread bearophile via Digitalmars-d-learn
ketmar: Jonathan explains it very well. i can add the only thing: don't use `const` until you forced to. ;-) In D use immutable (or const) everywhere you can. Possibly mark as immutable everything doesn't need to mutate. sure, you can cast `const` away in your code, but using `cast` is a

Re: Undefined reference error when array size is given

2015-01-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/20/15 9:07 AM, ketmar via Digitalmars-d-learn wrote: On Tue, 20 Jan 2015 07:00:31 -0500 Steven Schveighoffer via Digitalmars-d-learn wrote: https://issues.dlang.org/show_bug.cgi?id=14014 So it looks like it's a DMD bug and we should not include that module. sorry, i can't see how this

Re: rebind of const class variables

2015-01-20 Thread ketmar via Digitalmars-d-learn
On Tue, 20 Jan 2015 09:29:45 + qqiang via Digitalmars-d-learn wrote: > I am writing a tree data structure, and I have the following code: > > ```D > final class Node { > private { > int val_; > Node parent_; > Node left_; > Node right_; > } > > @proper

Re: Undefined reference error when array size is given

2015-01-20 Thread ketmar via Digitalmars-d-learn
On Tue, 20 Jan 2015 07:00:31 -0500 Steven Schveighoffer via Digitalmars-d-learn wrote: > On 1/19/15 4:49 PM, Steven Schveighoffer wrote: > > > I figured it out, poll.d is missing from here: > > > > https://github.com/D-Programming-Language/druntime/blob/master/mak/SRCS > > > > So it's for some r

Re: What is the "Final"?

2015-01-20 Thread bearophile via Digitalmars-d-learn
Rikki Cattermole: I'm guessing something along these lines: A Phobos patch: https://github.com/D-Programming-Language/phobos/pull/2881 Bye, bearophile

Re: What is the "Final"?

2015-01-20 Thread Kagamin via Digitalmars-d-learn
Probably borrowed from java: http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.12.4

Re: Undefined reference error when array size is given

2015-01-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/19/15 4:49 PM, Steven Schveighoffer wrote: I figured it out, poll.d is missing from here: https://github.com/D-Programming-Language/druntime/blob/master/mak/SRCS So it's for some reason not purposely included. I think there's an expectation (I'm probably guilty of this too) that if you i

Re: What is the "Final"?

2015-01-20 Thread Rikki Cattermole via Digitalmars-d-learn
On 21/01/2015 12:58 a.m., RuZzz wrote: Alexandrescu "The_D_Programming_Language" page 264: 7.1.10 Subtyping with structs. The @disable Attribute import std.stdio; ... unittest { auto a = Final!Widget(new Widget); a.print(); // Fine, just print a auto b = a; // Fine, a and b are bound to the same

What is the "Final"?

2015-01-20 Thread RuZzz via Digitalmars-d-learn
Alexandrescu "The_D_Programming_Language" page 264: 7.1.10 Subtyping with structs. The @disable Attribute import std.stdio; ... unittest { auto a = Final!Widget(new Widget); a.print(); // Fine, just print a auto b = a; // Fine, a and b are bound to the same Widget a = b; // Error! // opAssign(Fina

Re: ddoc template error

2015-01-20 Thread BlackEdder via Digitalmars-d-learn
On Tuesday, 20 January 2015 at 09:38:55 UTC, Mathias LANG wrote: On Tuesday, 20 January 2015 at 08:55:58 UTC, BlackEdder wrote: Solved it. I had a _fromJSON comment somewhere else in the file and the underscore causes ddoc to fail If you could reduce it to a manageable size and post it to h

Re: Number of Bits Needed to Represent a Zero-Offset Integer

2015-01-20 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Monday, 19 January 2015 at 21:23:47 UTC, Nordlöw wrote: On Monday, 19 January 2015 at 20:54:50 UTC, Steven Schveighoffer wrote: Cool. I would point out that the commented code suggests you should be handling the 0 case, but you are not (when T.min == T.max) I believe that should trigger a

Re: rebind of const class variables

2015-01-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 20, 2015 09:29:45 qqiang via Digitalmars-d-learn wrote: > I am writing a tree data structure, and I have the following code: > > ```D > final class Node { > private { > int val_; > Node parent_; > Node left_; > Node right_; > } > > @property > const(N

Re: ddoc template error

2015-01-20 Thread Mathias LANG via Digitalmars-d-learn
On Tuesday, 20 January 2015 at 08:55:58 UTC, BlackEdder wrote: Solved it. I had a _fromJSON comment somewhere else in the file and the underscore causes ddoc to fail If you could reduce it to a manageable size and post it to https://issues.dlang.org/ that'll be super cool :)

Re: rebind of const class variables

2015-01-20 Thread Mathias LANG via Digitalmars-d-learn
On Tuesday, 20 January 2015 at 09:29:46 UTC, qqiang wrote: I am writing a tree data structure, and I have the following code: ```D final class Node { private { int val_; Node parent_; Node left_; Node right_; } @property const(Node) maximum() con

rebind of const class variables

2015-01-20 Thread qqiang via Digitalmars-d-learn
I am writing a tree data structure, and I have the following code: ```D final class Node { private { int val_; Node parent_; Node left_; Node right_; } @property const(Node) maximum() const { auto ret = this;

Re: ddoc template error

2015-01-20 Thread BlackEdder via Digitalmars-d-learn
Solved it. I had a _fromJSON comment somewhere else in the file and the underscore causes ddoc to fail On Monday, 19 January 2015 at 20:47:42 UTC, BlackEdder wrote: I'm trying to use ddoc to generate documentation, but get the following error: $ dub -b docs Building configuration "library", bu