Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread Seb via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 20:57:02 UTC, Steven Schveighoffer wrote: On 7/10/18 4:02 PM, Per Nordlöw wrote: On Tuesday, 10 July 2018 at 19:27:07 UTC, Steven Schveighoffer wrote: On 7/10/18 3:01 PM, Per Nordlöw wrote: [...] Yes, call this function on startup: import etc.linux :  registerMem

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread Neia Neutuladh via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 22:53:25 UTC, kdevel wrote: extern (C) __gshared bool rt_trapExceptions; static this () { rt_trapExceptions = false; } This will catch exceptions raised in main and in static constructors that run after this one. However, if you put that code in t

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 22:31:54 UTC, Adam D. Ruppe wrote: Turn off rtTrapExceptions though the command line switch PR is STILL NOT MERGED https://github.com/dlang/druntime/pull/2035 extern (C) __gshared bool rt_trapExceptions; static this () { rt_trapExceptions = false

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 21:18:01 UTC, kdevel wrote: but how do I force the runtime to generate a coredump for real post-mortem analysis? Turn off rtTrapExceptions though the command line switch PR is STILL NOT MERGED https://github.com/dlang/druntime/pull/2035 come on, people.

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/18 5:18 PM, kdevel wrote: On Tuesday, 10 July 2018 at 21:09:23 UTC, Steven Schveighoffer wrote: [...] As far as the OS is concerned, a[2 .. $] is within the process memory limit. Of course, that's an out of bounds access, so the compiler or the bounds check *should* complain. It com

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 19:27:07 UTC, Steven Schveighoffer wrote: import etc.linux : registerMemoryErrorHandler; Needs to be: import etc.linux.memoryerror : registerMemoryErrorHandler;

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 21:09:23 UTC, Steven Schveighoffer wrote: [...] As far as the OS is concerned, a[2 .. $] is within the process memory limit. Of course, that's an out of bounds access, so the compiler or the bounds check *should* complain. It complains at runtime > ./dumpme2

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/18 5:01 PM, kdevel wrote: On Tuesday, 10 July 2018 at 20:10:54 UTC, Adam D. Ruppe wrote: On Tuesday, 10 July 2018 at 19:01:22 UTC, Per Nordlöw wrote: [...] Run the program in a debugger, or run `ulimit -c unlimited` to enable core dumps [...] Works for null ptr deref but how do I enf

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 20:10:54 UTC, Adam D. Ruppe wrote: On Tuesday, 10 July 2018 at 19:01:22 UTC, Per Nordlöw wrote: [...] Run the program in a debugger, or run `ulimit -c unlimited` to enable core dumps [...] Works for null ptr deref but how do I enforce core dumps in this code: du

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/18 4:02 PM, Per Nordlöw wrote: On Tuesday, 10 July 2018 at 19:27:07 UTC, Steven Schveighoffer wrote: On 7/10/18 3:01 PM, Per Nordlöw wrote: Is it possible to change run-time behaviour of null-class dereferencing, on Linux, so that it gives some other diagnostics than: Program exited w

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

2018-07-10 Thread Seb 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, anywhere

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread Seb via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 19:01:22 UTC, Per Nordlöw wrote: Is it possible to change run-time behaviour of null-class dereferencing, on Linux, so that it gives some other diagnostics than: Program exited with code -11 Does DMD and LDC provide different alternatives here? On a Systemd syste

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 19:01:22 UTC, Per Nordlöw wrote: Is it possible to change run-time behaviour of null-class dereferencing, on Linux, so that it gives some other diagnostics than: Run the program in a debugger, or run `ulimit -c unlimited` to enable core dumps so you can run a debug

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 19:27:07 UTC, Steven Schveighoffer wrote: On 7/10/18 3:01 PM, Per Nordlöw wrote: Is it possible to change run-time behaviour of null-class dereferencing, on Linux, so that it gives some other diagnostics than: Program exited with code -11 Does DMD and LDC provide

Re: Better diagnostics for null classes dereferencing

2018-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/18 3:01 PM, Per Nordlöw wrote: Is it possible to change run-time behaviour of null-class dereferencing, on Linux, so that it gives some other diagnostics than: Program exited with code -11 Does DMD and LDC provide different alternatives here? Yes, call this function on startup: impo

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.

Better diagnostics for null classes dereferencing

2018-07-10 Thread Per Nordlöw via Digitalmars-d-learn
Is it possible to change run-time behaviour of null-class dereferencing, on Linux, so that it gives some other diagnostics than: Program exited with code -11 Does DMD and LDC provide different alternatives here?

Re: Troubles creating templated inout objects

2018-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/18 10:34 AM, Timoses wrote: How do I create an inout object with template parameters? Take following code: import std.stdio; import std.traits; struct S {     int[] arr; } interface I {     inout(I) opIndex(size_t idx) inout; } c

Re: Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

2018-07-10 Thread Timoses via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 14:58:42 UTC, vino.B wrote: Hi Alex, I am getting the output as tuples of multiple arrays, but the requirement is to get the all the tuple in a single array like the below so that we can perform sorting and printing the output is easy. Something along the way

Re: Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

2018-07-10 Thread vino.B via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 14:50:53 UTC, Alex wrote: On Tuesday, 10 July 2018 at 14:38:03 UTC, vino.B wrote: Hi Alex, The reason the I am storing the output of "PFresult.toRange" to another array "rData" is that the output of the PFresult.toRange is different each time we execute the cod

Re: Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

2018-07-10 Thread Alex via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 14:38:03 UTC, vino.B wrote: Hi Alex, The reason the I am storing the output of "PFresult.toRange" to another array "rData" is that the output of the PFresult.toRange is different each time we execute the code.(Data is correct) but the way the it output is differ

Re: Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

2018-07-10 Thread vino.B via Digitalmars-d-learn
On Monday, 9 July 2018 at 18:07:49 UTC, Alex wrote: On Monday, 9 July 2018 at 17:26:30 UTC, vino.B wrote: Request Help: void process(alias coRoutine, T...)(Array!string Dirlst, T params) { ReturnType!coRoutine rData; / This line is not working alias scRType = typeof(coRout

Troubles creating templated inout objects

2018-07-10 Thread Timoses via Digitalmars-d-learn
How do I create an inout object with template parameters? Take following code: import std.stdio; import std.traits; struct S { int[] arr; } interface I { inout(I) opIndex(size_t idx) inout; }

Re: guard clause style static if

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 11:56:40 UTC, rikki cattermole wrote: void bar (T ...) (T args) if (T.length == 0) { return; [...] } void bar (T ...) (T args) if (T.length > 0) { writeln (args [0]); return bar (args [1 .. $]); } This is a version without a se

Re: vibe.d: problematic "Non-@safe methods are deprecated in REST interfaces"

2018-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 10 July 2018 07:24:43 MDT WebFreak001 via Digitalmars-d-learn wrote: > On Tuesday, 10 July 2018 at 13:14:24 UTC, Piotr Mitana wrote: > > Hello, > > > > I've recently started building a little REST application on > > vibe.d. I decided to use the "database" library, as I need to > > comm

Re: guard clause style static if

2018-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/18 7:38 AM, kdevel wrote: On Tuesday, 10 July 2018 at 00:11:27 UTC, Steven Schveighoffer wrote: On 7/7/18 7:28 AM, kdevel wrote: It appears not to be possible to use static if in "guard clause style" as in     void bar (T ...) (T args)     {    static if (args.length == 0)    

Re: vibe.d: problematic "Non-@safe methods are deprecated in REST interfaces"

2018-07-10 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 13:14:24 UTC, Piotr Mitana wrote: Hello, I've recently started building a little REST application on vibe.d. I decided to use the "database" library, as I need to communicate with the PostgreSQL instance. During the compilation I see the deprecation warning: "Non-

vibe.d: problematic "Non-@safe methods are deprecated in REST interfaces"

2018-07-10 Thread Piotr Mitana via Digitalmars-d-learn
Hello, I've recently started building a little REST application on vibe.d. I decided to use the "database" library, as I need to communicate with the PostgreSQL instance. During the compilation I see the deprecation warning: "Non-@safe methods are deprecated in REST interfaces" So two questi

Re: guard clause style static if

2018-07-10 Thread Timoses via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 12:10:27 UTC, Jonathan M Davis wrote: On Tuesday, 10 July 2018 05:38:33 MDT kdevel via Digitalmars-d-learn wrote: I would like to suggest an extension of the language by introducing static return Expression_opt; which shall have the effect of a return plus tha

Re: guard clause style static if

2018-07-10 Thread Timoses via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 12:05:11 UTC, kdevel wrote: On Saturday, 7 July 2018 at 13:12:59 UTC, Alex wrote: The site you cited for the guard clause above (c2.com) works at runtime. ? static if works at compile team and only inserts code into the final code for run-time depending on the co

Re: guard clause style static if

2018-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 10 July 2018 05:38:33 MDT kdevel via Digitalmars-d-learn wrote: > I would like to suggest an extension of the language by > introducing > > static return Expression_opt; > > which shall have the effect of a return plus that the remaining > lines in the current block are treated as

Re: guard clause style static if

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 13:12:59 UTC, Alex wrote: The site you cited for the guard clause above (c2.com) works at runtime. ? The intention is to shorten the paths inside a function, I think. Therefore, a static "guard clause" is a contradiction, if I understand it correctly. The term "

Re: guard clause style static if

2018-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 10 July 2018 05:52:59 MDT kdevel via Digitalmars-d-learn wrote: > On Saturday, 7 July 2018 at 13:03:32 UTC, rikki cattermole wrote: > > void func() { > > > > return; > > > > func2(); > > > > } > > > > Which is clearly an error. Hence why you need to add else block. > > There is

Re: guard clause style static if

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 13:03:32 UTC, rikki cattermole wrote: void func() { return; func2(); } Which is clearly an error. Hence why you need to add else block. There is no error in this generated code because func2 is unreachable. That there is a state/stage during compil

Re: guard clause style static if

2018-07-10 Thread kdevel via Digitalmars-d-learn
On Tuesday, 10 July 2018 at 00:11:27 UTC, Steven Schveighoffer wrote: On 7/7/18 7:28 AM, kdevel wrote: It appears not to be possible to use static if in "guard clause style" as in    void bar (T ...) (T args)    {   static if (args.length == 0) return;   writeln (args [0

Re: BetterC and TypeInfo Question

2018-07-10 Thread ARaspiK via Digitalmars-d-learn
On Friday, 23 June 2017 at 04:03:04 UTC, Adam D. Ruppe wrote: On Friday, 23 June 2017 at 02:49:27 UTC, Mike wrote: My approaches are right now for -betterC to be a filthy hack to get it working quick, and I still have a bunch of ways I want to improve the implementation and compiler interface i