Re: Question about the $ sign in arrays and strings

2020-02-18 Thread Namal via Digitalmars-d-learn
oooh... I used str = std.readln(); to get my string and there must have been some other sign, line break or whitespace or something at the end :( Now I understand it, thx

Re: Question about the $ sign in arrays and strings

2020-02-18 Thread mipri via Digitalmars-d-learn
On Wednesday, 19 February 2020 at 07:04:48 UTC, Namal wrote: Hello, I wanted to remove the lastchar in a string and figured that you can do that wit str = str[0..$-2]; but why is str = str[0..$] and str=str[0..$-1] the same ? Why do you think that they are the same? $ rdmd --eval 'auto

State of MIPS

2020-02-18 Thread April via Digitalmars-d-learn
What's the current state of MIPS compiling for bare metal? Especially the R4300i processor. I see MIPS on both GDC and LDC "partial support/bare metal" lists but them being somewhat vague about it I'm not quite sure which it means and I'm sure by now the processors and instruction sets are

Question about the $ sign in arrays and strings

2020-02-18 Thread Namal via Digitalmars-d-learn
Hello, I wanted to remove the lastchar in a string and figured that you can do that wit str = str[0..$-2]; but why is str = str[0..$] and str=str[0..$-1] the same ?

Re: Two problems with json and lcd

2020-02-18 Thread Petar via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 18:05:43 UTC, AlphaPurned wrote: json has two issues, it doesn't work with tuple: (isArray!T) goes to (isArray!T || (T.stringof.length > 4 && T.stringof[0..5] == "Tuple")) and right below else { static assert(false, text(`unable

Two problems with json and lcd

2020-02-18 Thread AlphaPurned via Digitalmars-d-learn
json has two issues, it doesn't work with tuple: (isArray!T) goes to (isArray!T || (T.stringof.length > 4 && T.stringof[0..5] == "Tuple")) and right below else { static assert(false, text(`unable to convert type "`, T.Stringof, `" to json`)); } and it

Conditional Attributes

2020-02-18 Thread Marcel via Digitalmars-d-learn
Hello! Say I have a struct where every member function can either be static or not depending on a template parameter. Is there a simple way to do this? Like, for example: struct Foo(Condition) { static if (Condition) static: void Bar() {} void Baz() {} }

Re: How to catch RangeError in unittest?

2020-02-18 Thread wjoe via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 13:07:35 UTC, wjoe wrote: I have a function add(index, data) which throws RangeError if the index is invalid. Never mind. For whatever reason RangeError is now caught. Sorry for the noise.

Re: Alternative to friend functions?

2020-02-18 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 12:43:22 UTC, Adnan wrote: class Wife(uint N) : Female { FemaleID engagedTo = -1; const MaleID[N] preferences; this(MaleID[N] preferences) { this.preferences = preferences; } } void engage(N)(ref Wife!N, wife, ref Husband!N husband) {

How to catch RangeError in unittest?

2020-02-18 Thread wjoe via Digitalmars-d-learn
I have a function add(index, data) which throws RangeError if the index is invalid. unittest { // is supposed to test that RangeError is thrown on a range violation assertThrown!RangeError(add(size_t.max, something)); //which doesn't work, the test is killed with core.exception.RangeError:

Re: How to declare a virtual member (not a function) in a class

2020-02-18 Thread Petar via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 12:37:45 UTC, Adnan wrote: I have a base class that has a couple of constant member variables. These variables are abstract, they will only get defined when the derived class gets constructed. class Person { const string name; const int id; } class

Re: Alternative to friend functions?

2020-02-18 Thread Petar via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 12:43:22 UTC, Adnan wrote: What is the alternative to C++'s friend functions in D? module stable_matching; alias FemaleID = int; alias MaleID = int; class Person { string name; int id; } class Male : Person { this(string name = "Unnamed Male") {

Re: How to declare a virtual member (not a function) in a class

2020-02-18 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 12:37:45 UTC, Adnan wrote: I have a base class that has a couple of constant member variables. These variables are abstract, they will only get defined when the derived class gets constructed. class Person { const string name; const int id; } class

Alternative to friend functions?

2020-02-18 Thread Adnan via Digitalmars-d-learn
What is the alternative to C++'s friend functions in D? module stable_matching; alias FemaleID = int; alias MaleID = int; class Person { string name; int id; } class Male : Person { this(string name = "Unnamed Male") { static int nextID = 0; this.id = nextID++;

How to declare a virtual member (not a function) in a class

2020-02-18 Thread Adnan via Digitalmars-d-learn
I have a base class that has a couple of constant member variables. These variables are abstract, they will only get defined when the derived class gets constructed. class Person { const string name; const int id; } class Male : Person { this(string name = "Unnamed Male") {

Re: How to get the name of an object's class at compile time?

2020-02-18 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 03:33:21 UTC, Basile B. wrote: On Monday, 17 February 2020 at 22:34:31 UTC, Stefan Koch wrote: Upon seeing this I just implemented typeid(stuff).name; https://github.com/dlang/dmd/pull/10796 With any luck this will be possible in the next release ;) Can this

Re: DPP: Linker issue with functions implemented in C header files

2020-02-18 Thread Petar via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 09:20:08 UTC, Andre Pany wrote: Hi Petar, Hi Andre, I'm happy to help :) thank you very much for the explanation and the code sample. Filling the az_span anonymous member was the tricky part, I thought it would be not possible to do so, but you showed me the

Re: betterC CTFE nested switch

2020-02-18 Thread Abby via Digitalmars-d-learn
On Monday, 17 February 2020 at 19:02:50 UTC, Stefan Koch wrote: Sorry I just realized I never published the code. I am going to add it to ctfeutils. Thank you very much

Re: DPP: Linker issue with functions implemented in C header files

2020-02-18 Thread Andre Pany via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 08:32:47 UTC, Petar Kirov [ZombineDev] wrote: On Tuesday, 18 February 2020 at 05:41:38 UTC, Andre Pany wrote: Hi, I try to get wrap the "Azure SDK for C" using DPP and have following issue. Functions, which are actually implemented in C header files will cause

Re: DPP: Linker issue with functions implemented in C header files

2020-02-18 Thread Petar via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 05:41:38 UTC, Andre Pany wrote: Hi, I try to get wrap the "Azure SDK for C" using DPP and have following issue. Functions, which are actually implemented in C header files will cause linker errors: