Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-19 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
On Monday, 19 November 2018 at 21:57:11 UTC, Neia Neutuladh wrote: Programmers coming from nearly any language other than C++ would find it expected and intuitive that declaring a class instance variable leaves it null. What do you think about making the syntax slightly more explicit and

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-19 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
On Monday, 19 November 2018 at 21:52:47 UTC, Steven Schveighoffer wrote: A null pointer dereference is an immediate error, and it's also a safe error. It does not cause corruption, and it is free (the MMU is doing it for you). Is this always true for all arches that D can compile to? I

Why does nobody seem to think that `null` is a serious problem in D?

2018-11-19 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
When I was first playing with D, I managed to create a segfault by doing `SomeClass c;` and then trying do something with the object I thought I had default-created, by analogy with C++ syntax. Seasoned D programmers will recognise that I did nothing of the sort and instead created c is null

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

2018-07-11 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 20:28:00 UTC, Seb wrote: Maybe looking at the recent DMD Backend to D conversion PRs (https://github.com/dlang/dmd/pulls?utf8=%E2%9C%93=is%3Apr+label%3A%22D+Conversion%22+) helps? Here -betterC is used. Octave is so far from -betterC, though. It's very

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

2018-07-10 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
On Wednesday, 20 June 2018 at 19:57:55 UTC, jmh530 wrote: I'm not sure adding D to the GNU Octave code base is necessarily the biggest value add... I'm daydreaming of being able to rewrite all of Octave in D. I just was trying to think of where to start.

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

2018-06-20 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
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, anywhere. Now, as I understand it, I would need to begin with making `main` a D

Re: What's the proper way to use std.getopt?

2017-12-12 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 20:57:28 UTC, Jon Degenhardt wrote: On Monday, 11 December 2017 at 20:58:25 UTC, Jordi Gutiérrez Hermoso wrote: What's the proper style, then? Can someone show me a good example of how to use getopt and the docstring it automatically generates? [snip] See:

Re: What's the proper way to use std.getopt?

2017-12-11 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
On Monday, 11 December 2017 at 21:24:41 UTC, Mike Wey wrote: try { auto helpInformation = getopt( args, "input|i", "The input", , "output|o", "The output", ); if (helpInformation.helpWanted) {

Re: Why is there no std.stream anymore?

2017-12-11 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
On Monday, 11 December 2017 at 21:21:51 UTC, Steven Schveighoffer wrote: Use the undead repository: Wow, really? Is the removal of stream from D some kind of error that hasn't been corrected yet?

What's the proper way to use std.getopt?

2017-12-11 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
I don't quite understand what to do if getopt throws. I would have hoped for something like int arg1; string arg2; auto parser = getopt("opt1", "docstring 1", , "opt2", "docstring 2", ); try { auto opts = parser.parse(args) } except(BadArguments) {

Why is there no std.stream anymore?

2017-12-11 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
I'd like to read from a file, one byte at a time, without loading the whole file in memory. I was hoping I could do something like auto f = File("somefile"); foreach(c; f.byChar) { process(c); } but there appears to be no such way to do it anymore. Instead, the stdlib seems