Re: Is it feasible to slowly rewrite a C++ codebase in D?

2018-07-13 Thread Vladimir Panteleev via Digitalmars-d-learn
On Friday, 13 July 2018 at 07:51:51 UTC, Dukc wrote: I know about Vladimir's d-scripten tools library which would help, but it's based on Alawains library copyleft library, which makes also Vladimir's work copyleft, so I won't use it. Hmm, I wasn't aware of this. I wonder if the decision to

Re: @safe - why does this compile?

2018-07-13 Thread Dukc via Digitalmars-d-learn
On Friday, 13 July 2018 at 13:52:27 UTC, Timoses wrote: I suppose this is another good example of how casting can be dangerous? E.g. also: immutable int i = 3; int* j = cast(int*) assert(i == 3); *j = 4; assert(j == ); // data occupies same address space assert(i

Re: Orange not working?

2018-07-13 Thread JN via Digitalmars-d-learn
On Friday, 13 July 2018 at 19:03:32 UTC, Jacob Carlborg wrote: On 2018-07-13 20:52, Jacob Carlborg wrote: Orange master is working properly. The tests are run on each push and PR with the latest DMD compiler. I just added a cron job in Travis CI as well to make sure it every month even

Re: Is it feasible to slowly rewrite a C++ codebase in D?

2018-07-13 Thread Laeeth Isharc via Digitalmars-d-learn
On Wednesday, 20 June 2018 at 18:47:10 UTC, Jordi Gutiérrez Hermoso wrote: I'm specifically thinking of the GNU Octave codebase: http://hg.savannah.gnu.org/hgweb/octave/file/@ It's a fairly old and complicated C++ codebase. I would like to see if I could slowly introduce some D in it,

Re: Check whether a range is empty

2018-07-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/13/18 3:29 PM, vino.B wrote: On Friday, 13 July 2018 at 19:05:20 UTC, Steven Schveighoffer wrote: On 7/13/18 2:37 PM, vino.B wrote: Hi All,    How do i check whether a range is empty. eg. (!PFResutl.toRange).empty. I tired the below, but it is no printing Empty if the range is empty it

Re: Check whether a range is empty

2018-07-13 Thread vino.B via Digitalmars-d-learn
On Friday, 13 July 2018 at 19:05:20 UTC, Steven Schveighoffer wrote: On 7/13/18 2:37 PM, vino.B wrote: Hi All,   How do i check whether a range is empty. eg. (!PFResutl.toRange).empty. I tired the below, but it is no printing Empty if the range is empty it just prints blank line. if

Re: Check whether a range is empty

2018-07-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/13/18 2:37 PM, vino.B wrote: Hi All,   How do i check whether a range is empty. eg. (!PFResutl.toRange).empty. I tired the below, but it is no printing Empty if the range is empty it just prints blank line. if (!(!PFResutl.toRange).empty) { writeln("Empty"); } Without knowing what

Re: Orange not working?

2018-07-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-07-13 20:52, Jacob Carlborg wrote: Orange master is working properly. The tests are run on each push and PR with the latest DMD compiler. I just added a cron job in Travis CI as well to make sure it every month even though there hasn't been a commit. This will make sure it always

Re: Orange not working?

2018-07-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-07-13 14:59, Timoses wrote: Huh, see this issue on github: https://github.com/jacob-carlborg/orange/issues/39 which references to https://github.com/jacob-carlborg/mambo . Although that repository has last been updated in 2016 whereas Orange's was Oct. 2017. Yeah, Mambo was a

Re: Orange not working?

2018-07-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-07-12 22:44, JN wrote: I am trying to make use of the Orange package, I added the latest version from dub to my project: "orange": "~>1.0.0" and copy pasted the "simple usage" code from https://github.com/jacob-carlborg/orange , but I am getting a long list of errors:

Check whether a range is empty

2018-07-13 Thread vino.B via Digitalmars-d-learn
Hi All, How do i check whether a range is empty. eg. (!PFResutl.toRange).empty. I tired the below, but it is no printing Empty if the range is empty it just prints blank line. if (!(!PFResutl.toRange).empty) { writeln("Empty"); } From, Vino.B

Re: @safe - why does this compile?

2018-07-13 Thread ketmar via Digitalmars-d-learn
Steven Schveighoffer wrote: To emphasize the point, this is @safe as well: X2 x2; // = null x2.run(); D does not consider a segmentation fault due to null dereferencing to be unsafe -- no memory corruption happens. yeah. in simple words: safe code is *predictable*, but not "segfault-less".

Re: @safe - why does this compile?

2018-07-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/13/18 7:22 AM, ketmar wrote: Piotr Mitana wrote: This code: import std.stdio; class X1 {} class X2 : X1 { void run() @safe { writeln("DONE"); } } void main() @safe { X1 x1 = new X1; X2 x2 = cast(X2)

Re: @safe - why does this compile?

2018-07-13 Thread Timoses via Digitalmars-d-learn
On Friday, 13 July 2018 at 11:04:40 UTC, Piotr Mitana wrote: This code: import std.stdio; class X1 {} class X2 : X1 { void run() @safe { writeln("DONE"); } } void main() @safe { X1 x1 = new X1; X2 x2 = cast(X2)

Re: Orange not working?

2018-07-13 Thread Timoses via Digitalmars-d-learn
On Friday, 13 July 2018 at 05:39:24 UTC, JN wrote: On Friday, 13 July 2018 at 05:29:58 UTC, Timoses wrote: On Thursday, 12 July 2018 at 20:44:43 UTC, JN wrote: I am trying to make use of the Orange package, I added the latest version from dub to my project: "orange": "~>1.0.0" and copy pasted

Re: @safe - why does this compile?

2018-07-13 Thread bauss via Digitalmars-d-learn
On Friday, 13 July 2018 at 11:04:40 UTC, Piotr Mitana wrote: This code: import std.stdio; class X1 {} class X2 : X1 { void run() @safe { writeln("DONE"); } } void main() @safe { X1 x1 = new X1; X2 x2 = cast(X2)

Re: UFCS confusion

2018-07-13 Thread Michael via Digitalmars-d-learn
On Friday, 13 July 2018 at 11:17:32 UTC, Radu wrote: On Friday, 13 July 2018 at 11:12:47 UTC, Michael wrote: On Friday, 13 July 2018 at 10:52:54 UTC, Radu wrote: On Friday, 13 July 2018 at 10:21:54 UTC, Michael wrote: [...] Do you try to call member functions? UFCS only works with free

Re: @safe - why does this compile?

2018-07-13 Thread ketmar via Digitalmars-d-learn
Piotr Mitana wrote: This code: import std.stdio; class X1 {} class X2 : X1 { void run() @safe { writeln("DONE"); } } void main() @safe { X1 x1 = new X1; X2 x2 = cast(X2) x1; x2.run(); }

Re: UFCS confusion

2018-07-13 Thread Radu via Digitalmars-d-learn
On Friday, 13 July 2018 at 11:12:47 UTC, Michael wrote: On Friday, 13 July 2018 at 10:52:54 UTC, Radu wrote: On Friday, 13 July 2018 at 10:21:54 UTC, Michael wrote: [...] Do you try to call member functions? UFCS only works with free functions, meaning declared at module level.

Re: UFCS confusion

2018-07-13 Thread Michael via Digitalmars-d-learn
On Friday, 13 July 2018 at 10:52:54 UTC, Radu wrote: On Friday, 13 July 2018 at 10:21:54 UTC, Michael wrote: Hello, I am nesting some function calls, and I'm pretty used to making use of D's Uniform Function Call Syntax, but I'm getting an error if I try to convert this line:

@safe - why does this compile?

2018-07-13 Thread Piotr Mitana via Digitalmars-d-learn
This code: import std.stdio; class X1 {} class X2 : X1 { void run() @safe { writeln("DONE"); } } void main() @safe { X1 x1 = new X1; X2 x2 = cast(X2) x1; x2.run(); } is obviously wrong gets killed by

Re: UFCS confusion

2018-07-13 Thread Radu via Digitalmars-d-learn
On Friday, 13 July 2018 at 10:21:54 UTC, Michael wrote: Hello, I am nesting some function calls, and I'm pretty used to making use of D's Uniform Function Call Syntax, but I'm getting an error if I try to convert this line: createSet(createVector(langSize, index)).length; which works,

UFCS confusion

2018-07-13 Thread Michael via Digitalmars-d-learn
Hello, I am nesting some function calls, and I'm pretty used to making use of D's Uniform Function Call Syntax, but I'm getting an error if I try to convert this line: createSet(createVector(langSize, index)).length; which works, into this line: createVector(langSize,

Re: Is it feasible to slowly rewrite a C++ codebase in D?

2018-07-13 Thread Dukc via Digitalmars-d-learn
On Wednesday, 20 June 2018 at 18:47:10 UTC, Jordi Gutiérrez Hermoso wrote: Now, as I understand it, I would need to begin with making `main` a D function, because D needs to initialise the runtime. Is this correct? No. Some initialization is required if you use the GC, as I understand it.

Re: Is it feasible to slowly rewrite a C++ codebase in D?

2018-07-13 Thread Dukc via Digitalmars-d-learn
On Thursday, 12 July 2018 at 15:12:51 UTC, Seb wrote: it might also be feasible to simply use normal D. Have you already tried this? There's no strict distinction between using D normally and in systems programming fashion for me, because my main function isn't written in D. But in