Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-20 Thread Mathias LANG via Digitalmars-d-learn
On Wednesday, 21 July 2021 at 03:25:03 UTC, apz28 wrote: with below error message: ..\..\pham\db\db_skdatabase.d(140): Error: null dereference in function _D4pham2db10fbdatabase7FbArray__T13readArrayImplTbZQsMFNfCQCeQCc8database12DbNameColumnZAb ..\..\pham\db\db_skdatabase.d(139): Error: null

Re: Not allowed to globally overload operators?

2021-07-20 Thread Tejas via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 18:32:26 UTC, Ali Çehreli wrote: On 7/19/21 11:20 PM, Tejas wrote: > trying to create the spaceship operator of C++ Just to make sure, D's opCmp returns an int. That new C++ operator was added to provide the same semantics. Ali I know. As I already mentioned,

How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-20 Thread apz28 via Digitalmars-d-learn
VisualD project - Any hint to work around DMD version: DMD32 D Compiler v2.096.0-rc.1-dirty Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved written by Walter Bright Failed Build Command line: dmd -release -m32mscoff -O -inline -dip25 -dip1000 -preview=fixAliasThis

Re: How to parse a json node that contains children of different types?

2021-07-20 Thread Mathias LANG via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 21:18:12 UTC, Bagomot wrote: But there is a problem with different types. I understand that Object[] is not suitable here, but I don’t know how to do it. I ask you to help me with this. IIUC, the `arguments` are command line arguments passed to a Java program,

How to parse a json node that contains children of different types?

2021-07-20 Thread Bagomot via Digitalmars-d-learn
I have a json like this: ```json { "arguments":{ "jvm":[ { "rules":[ { "action":"allow", "os":{ "name":"osx" } } ], "value":[

Re: Not allowed to globally overload operators?

2021-07-20 Thread Ali Çehreli via Digitalmars-d-learn
On 7/20/21 11:49 AM, H. S. Teoh wrote: > On Tue, Jul 20, 2021 at 11:32:26AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: >> On 7/19/21 11:20 PM, Tejas wrote: >> >>> trying to create the spaceship operator of C++ >> >> Just to make sure, D's opCmp returns an int. That new C++ operator was

Re: Not allowed to globally overload operators?

2021-07-20 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 18:49:07 UTC, H. S. Teoh wrote: On Tue, Jul 20, 2021 at 11:32:26AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: On 7/19/21 11:20 PM, Tejas wrote: > trying to create the spaceship operator of C++ Just to make sure, D's opCmp returns an int. That new C++

Re: Not allowed to globally overload operators?

2021-07-20 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 20, 2021 at 11:32:26AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 7/19/21 11:20 PM, Tejas wrote: > > > trying to create the spaceship operator of C++ > > Just to make sure, D's opCmp returns an int. That new C++ operator was > added to provide the same semantics. [...]

Re: Not allowed to globally overload operators?

2021-07-20 Thread Ali Çehreli via Digitalmars-d-learn
On 7/19/21 11:20 PM, Tejas wrote: > trying to create the spaceship operator of C++ Just to make sure, D's opCmp returns an int. That new C++ operator was added to provide the same semantics. Ali

Re: Can static variables in methods be local for each object?

2021-07-20 Thread Dukc via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 09:24:07 UTC, Mark Lagodych wrote: Is there a way to make myvar local to each instance of `X` without making it a variable of `X`? Just curious. Yes. ```d import std.stdio; class X { int x(int param) { static int[typeof(this)] myvar; if (param

Re: Can static variables in methods be local for each object?

2021-07-20 Thread bauss via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 09:24:07 UTC, Mark Lagodych wrote: Let's say I have this code: ```d import std.stdio; class X { int x(int param) { static int myvar = 1234; if (param == 0) return myvar; else { myvar = param; return myvar; } } } void main() { X

Re: Can static variables in methods be local for each object?

2021-07-20 Thread Mark Lagodych via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 09:24:07 UTC, Mark Lagodych wrote: ```d void main() { X x1 = new X; X x2 = new X; x1.x(0).writeln; x2.x(0).writeln; x1.x(17).writeln; x2.x(0).writeln; } ``` Ow, sorry, I forgot to say. It prints: ``` 1234 1234 17 17 ```

Can static variables in methods be local for each object?

2021-07-20 Thread Mark Lagodych via Digitalmars-d-learn
Let's say I have this code: ```d import std.stdio; class X { int x(int param) { static int myvar = 1234; if (param == 0) return myvar; else { myvar = param; return myvar; } } } void main() { X x1 = new X; X x2 = new X; x1.x(0).writeln;

Re: Not allowed to globally overload operators?

2021-07-20 Thread Tejas via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 06:34:45 UTC, vit wrote: On Tuesday, 20 July 2021 at 06:20:34 UTC, Tejas wrote: ... Initially, I was trying to create the spaceship operator of C++, but we aren't allowed to create new operators ... D has spaceship operator: opCmp

Re: Not allowed to globally overload operators?

2021-07-20 Thread Tejas via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 06:30:56 UTC, Mike Parker wrote: On Tuesday, 20 July 2021 at 06:20:34 UTC, Tejas wrote: Why isn't it working by default? Initially, I was trying to create the spaceship operator of C++, but we aren't allowed to create new operators, it seems. Then I just wanted to

Re: Not allowed to globally overload operators?

2021-07-20 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 06:20:34 UTC, Tejas wrote: Why isn't it working by default? Initially, I was trying to create the spaceship operator of C++, but we aren't allowed to create new operators, it seems. Then I just wanted to verify whether we can even overload an operator globally,

Re: Not allowed to globally overload operators?

2021-07-20 Thread vit via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 06:20:34 UTC, Tejas wrote: ... Initially, I was trying to create the spaceship operator of C++, but we aren't allowed to create new operators ... D has spaceship operator: opCmp (https://dlang.org/spec/operatoroverloading.html#compare).

Not allowed to globally overload operators?

2021-07-20 Thread Tejas via Digitalmars-d-learn
The following doesn't work: ```d import std; int opBinary(string s:"+")(int a, int b){ int result; ab? (result = 1): (result = 0); return result; } void main(){ int f = 1 + 5; writeln(f); } ``` It outputs 6 But if I manually write it as ```d int f = opBinary!"+"(1,5); ``` It

Re: Yet another parallel foreach + continue question

2021-07-20 Thread Ali Çehreli via Digitalmars-d-learn
On 7/19/21 5:07 PM, seany wrote: > Consider : > > for (int i = 0; i < max_value_of_i; i++) { > foreach ( j, dummyVar; myTaskPool.parallel(array_to_get_j_from, > my_workunitSize) { > > if ( boolean_function(i,j) ) continue; > double d =