Printing Tuple!(...)[] using for loop?

2021-07-01 Thread Kirill via Digitalmars-d-learn
I have a `Tuple!(string, ..., string)[] data` that I would like to print out: `a b c` `1 2 3` `4 5 6` Furthermore, I want to be able to print any N rows and M columns of that table. For instance: `b c` `2 3` or `1 2 3` `4 5

Re: Error: function `...` without `this` cannot be `const`

2021-07-01 Thread someone via Digitalmars-d-learn
On Thursday, 1 July 2021 at 19:15:50 UTC, Johan Lermer wrote: Isn't @property kind of deprecated? The docs state "experimental" not deprecated ... but what this means today I don't know.

how much "real-life" code can be marked @safe ?

2021-07-01 Thread someone via Digitalmars-d-learn
... just wondering: I am writing pretty trivial code, nothing out of the ordinary, and attempted to check how much of it could be marked safe ... - Lots of tiny common library functions are pretty easy - Getter/Setter properties are easy too - almost all this() constructors are a no-go

Re: Public and private versions of opIndex

2021-07-01 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 1 July 2021 at 20:23:41 UTC, Ben Jones wrote: I tried to to write 2 versions of opIndex: ``` public Type opIndex(IndexType x) const {... } //and private Type ref opIndex(IndexType x) { ... } ``` which doesn't seem to work because client code that has a non-const reference to my

Public and private versions of opIndex

2021-07-01 Thread Ben Jones via Digitalmars-d-learn
I have a struct which I would like to have a public opIndex which returns by value (so client code can't modify my internal array), and a private version which allows the implementing code to modify stuff with `this[whatever] = whatever`. I tried to to write 2 versions of opIndex: ``` public

Re: SegFault trying to chunk lazily joined ranges

2021-07-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/1/21 10:56 AM, Keivan Shah wrote: Using the handler I was able to get the stack trace and it seems that the segFault is caused by `joiner` trying to call `.save` on a null object leading to a `NullPointerError`. But I have not been able to debug it further. Mostly it seems that there is

Re: Unknown bug disallows growth of dynamic arrays

2021-07-01 Thread solidstate1991 via Digitalmars-d-learn
On Monday, 28 June 2021 at 20:55:44 UTC, solidstate1991 wrote: Here's the offending function: https://github.com/ZILtoid1991/collections-d/blob/master/source/collections/sortedlist.d#L38 It causes to throw an exception with `Access violation reading location` and a memory address, int the

Re: Error: function `...` without `this` cannot be `const`

2021-07-01 Thread Johan Lermer via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 19:40:40 UTC, someone wrote: Let's use @property instead of const: ```d struct Foo { @property int data() { return m_data; } // read property @property int data(int value) { return m_data = value; } // write property private: int m_data; } Isn't

SegFault trying to chunk lazily joined ranges

2021-07-01 Thread Keivan Shah via Digitalmars-d-learn
Hello, I am trying to create a lazy range that iterates and chunks data over an array of lazy ranges but the code seems to lead to segFaults. I have tried to reduce the issue to minimum possible code that reproduces the error. My hypothesis is I am doing something wrong leading to the